shell-command-to-string -> doom-call-process #1887
Minor optimization to remove a layer of indirection when starting processes.
This commit is contained in:
parent
873fc5c0db
commit
44d5e097c9
5 changed files with 46 additions and 45 deletions
|
@ -179,38 +179,38 @@ If ARG (universal argument), open selection in other-window."
|
|||
.type .file .line)))))
|
||||
|
||||
(defun +ivy--tasks (target)
|
||||
(let* (case-fold-search
|
||||
(task-tags (mapcar #'car +ivy-task-tags))
|
||||
(cmd
|
||||
(format "%s -H -S --no-heading -- %s %s"
|
||||
(or (when-let (bin (executable-find "rg"))
|
||||
(concat bin " --line-number"))
|
||||
(when-let (bin (executable-find "ag"))
|
||||
(concat bin " --numbers"))
|
||||
(error "ripgrep & the_silver_searcher are unavailable"))
|
||||
(shell-quote-argument
|
||||
(concat "\\s("
|
||||
(string-join task-tags "|")
|
||||
")([\\s:]|\\([^)]+\\):?)"))
|
||||
target)))
|
||||
(save-match-data
|
||||
(cl-loop with out = (shell-command-to-string cmd)
|
||||
for x in (and out (split-string out "\n" t))
|
||||
when (condition-case-unless-debug ex
|
||||
(let (case-fold-search)
|
||||
(cl-loop with task-tags = (mapcar #'car +ivy-task-tags)
|
||||
with out =
|
||||
(cdr
|
||||
(apply #'doom-call-process
|
||||
(append
|
||||
(or (when-let (bin (executable-find "rg"))
|
||||
(list bin "--line-number"))
|
||||
(when-let (bin (executable-find "ag"))
|
||||
(list bin "--numbers"))
|
||||
(user-error "ripgrep & the_silver_searcher are unavailable"))
|
||||
(list "-H" "-S" "--no-heading" "--"
|
||||
(concat "\\s("
|
||||
(string-join task-tags "|")
|
||||
")([\\s:]|\\([^)]+\\):?)")
|
||||
target))))
|
||||
for x in (and out (split-string out "\n" t))
|
||||
when (condition-case-unless-debug ex
|
||||
(string-match
|
||||
(concat "^\\([^:]+\\):\\([0-9]+\\):.+\\("
|
||||
(string-join task-tags "\\|")
|
||||
"\\):?\\s-*\\(.+\\)")
|
||||
x)
|
||||
(error
|
||||
(print! (red "Error matching task in file: (%s) %s")
|
||||
(error-message-string ex)
|
||||
(car (split-string x ":")))
|
||||
nil))
|
||||
collect `((type . ,(match-string 3 x))
|
||||
(desc . ,(match-string 4 x))
|
||||
(file . ,(match-string 1 x))
|
||||
(line . ,(match-string 2 x)))))))
|
||||
(error
|
||||
(print! (red "Error matching task in file: (%s) %s")
|
||||
(error-message-string ex)
|
||||
(car (split-string x ":")))
|
||||
nil))
|
||||
collect `((type . ,(match-string 3 x))
|
||||
(desc . ,(match-string 4 x))
|
||||
(file . ,(match-string 1 x))
|
||||
(line . ,(match-string 2 x))))))
|
||||
|
||||
(defun +ivy--tasks-open-action (x)
|
||||
"Jump to the file and line of the current task."
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
(interactive)
|
||||
(let* ((msg-path (car (plist-get (notmuch-tree-get-message-properties) :filename)))
|
||||
(temp (make-temp-file "notmuch-message-" nil ".eml")))
|
||||
(shell-command-to-string (format "cp '%s' '%s'" msg-path temp))
|
||||
(doom-call-process "cp" msg-path temp)
|
||||
(start-process-shell-command "email" nil (format "xdg-open '%s'" temp))))
|
||||
|
||||
;;;###autoload
|
||||
|
@ -108,7 +108,7 @@
|
|||
(interactive)
|
||||
(let* ((msg-path (car (plist-get (notmuch-show-get-message-properties) :filename)))
|
||||
(temp (make-temp-file "notmuch-message-" nil ".eml")))
|
||||
(shell-command-to-string (format "cp '%s' '%s'" msg-path temp))
|
||||
(doom-call-process "cp" msg-path temp)
|
||||
(start-process-shell-command "email" nil (format "xdg-open '%s'" temp))))
|
||||
|
||||
|
||||
|
|
|
@ -21,12 +21,12 @@ Make sure your src block has a :session param.")
|
|||
(defun +org--ob-ipython-generate-local-path-from-remote (session host params)
|
||||
"Given a remote SESSION with PARAMS and corresponding HOST, copy remote config to local, start a jupyter console to generate a new one."
|
||||
(let* ((runtime-dir
|
||||
(substring (shell-command-to-string (concat "ssh " host " jupyter --runtime-dir")) 0 -1))
|
||||
(cdr
|
||||
(doom-call-process "ssh " host "jupyter" "--runtime-dir")))
|
||||
(runtime-file (concat runtime-dir "/" "kernel-" session ".json"))
|
||||
(tramp-path (concat "/ssh:" host ":" runtime-file))
|
||||
(tramp-copy (concat (or +ob-ipython-local-runtime-dir
|
||||
(substring (shell-command-to-string "jupyter --runtime-dir")
|
||||
0 -1))
|
||||
(cdr (doom-call-process "jupyter" "--runtime-dir")))
|
||||
"/remote-" host "-kernel-" session ".json"))
|
||||
(local-path
|
||||
(concat
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue