Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding of connection type? #102

Open
alphapapa opened this issue Jun 16, 2018 · 1 comment
Open

Allow overriding of connection type? #102

alphapapa opened this issue Jun 16, 2018 · 1 comment

Comments

@alphapapa
Copy link

Hi John,

I'm having a problem using rg with async-start-process: BurntSushi/ripgrep#951

I tried to bind process-connection-type around async-start-process, but it has no effect because async-start-process rebinds it to nil before calling start-process. However, when I do this, it works:

(defun argh-start-process (name program finish-func &rest program-args)
  "Start the executable PROGRAM asynchronously.  See `async-start'.
PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the
process object when done.  If FINISH-FUNC is nil, the future
object will return the process object when the program is
finished.  Set DEFAULT-DIRECTORY to change PROGRAM's current
working directory."
  (let* ((buf (generate-new-buffer (concat "*" name "*")))
         ;; NOTE: Removed let-binding of process-connection-type.
         (proc (apply #'start-process name buf program program-args)))
    (with-current-buffer buf
      (set (make-local-variable 'async-callback) finish-func)
      (set-process-sentinel proc #'async-when-done)
      (unless (string= name "emacs")
        (set (make-local-variable 'async-callback-for-process) t))
      proc)))

(let ((default-directory directory)
      (process-connection-type 'pty))
  (argh-start-process "rg-scan-async" "nice"
                      (apply-partially #'magit-todos--rg-scan-async-callback magit-status-buffer)
                      "-n5"
                      "rg" "--column" magit-todos-ag-search-regexp))

Is there a reason it doesn't allow the connection type to be changed? If not, could it?

Thanks.

@thierryvolpiatto
Copy link
Collaborator

thierryvolpiatto commented Jun 16, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants