Skip to content

Commit a05a1ec

Browse files
committed
bdx: Fix higher verbosity setting messing up some commands
* bdx.el (bdx--run-sync-process): New function. (bdx-disassemble): (bdx-find-definition): Use it to run the process synchronously.
1 parent bdbb7c8 commit a05a1ec

File tree

1 file changed

+48
-45
lines changed

1 file changed

+48
-45
lines changed

bdx.el

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,32 @@ The ARGS list is filtered out to keep only non-nil values."
137137
(princ (format "Command: %S\n" cmd) (current-buffer))))
138138
cmd)))
139139

140+
(defun bdx--run-sync-process (args)
141+
"Run bdx process synchronously, passing ARGS to it.
142+
The output is inserted into the current buffer."
143+
(let* ((name (format "bdx-%s" (car args)))
144+
(process
145+
(make-process
146+
:name name
147+
:command (apply #'bdx--command args)
148+
:buffer (current-buffer)
149+
:stderr (with-current-buffer
150+
(get-buffer-create bdx-stderr-buffer)
151+
(goto-char (point-max))
152+
(let ((inhibit-read-only t))
153+
(insert "\n\n"))
154+
(current-buffer))
155+
:sentinel
156+
(lambda (proc _status)
157+
(let ((code (process-exit-status proc)))
158+
(unless (eq 0 code)
159+
(with-current-buffer (process-buffer proc)
160+
(insert
161+
(format
162+
"error: %s process failed with code %s"
163+
name code)))))))))
164+
(while (accept-process-output process))))
165+
140166

141167
;; Searching
142168

@@ -676,48 +702,27 @@ symbol."
676702
:action #'bdx-disassemble)
677703
(with-current-buffer (bdx--disassembly-buffer)
678704
(pcase-let (((map :name :demangled :path :section) symbol-plist))
679-
(let ((command
680-
(apply #'bdx--command "disass"
681-
(append (and bdx-disassembly-results-limit
682-
(list "-n" (number-to-string
683-
bdx-disassembly-results-limit)))
684-
(list
685-
(and name (format "fullname:\"%s\"" name))
686-
(and demangled
687-
(format "demangled:\"%s\"" demangled))
688-
(and path (format "path:\"%s\"" path))
689-
(and section
690-
(format "section:\"%s\"" section))))))
705+
(let ((args
706+
(append '("disass")
707+
(and bdx-disassembly-results-limit
708+
(list "-n" (number-to-string
709+
bdx-disassembly-results-limit)))
710+
(list
711+
(and name (format "fullname:\"%s\"" name))
712+
(and demangled
713+
(format "demangled:\"%s\"" demangled))
714+
(and path (format "path:\"%s\"" path))
715+
(and section
716+
(format "section:\"%s\"" section)))))
691717
(current-state
692718
(and bdx-disassembly-current-symbol
693719
(list bdx-disassembly-current-symbol
694720
(point) (window-start))))
695-
(inhibit-read-only t)
696-
process)
721+
(inhibit-read-only t))
697722
(erase-buffer)
698723

699724
(pop-to-buffer (current-buffer))
700-
(setq process
701-
(make-process
702-
:name "bdx-disassembly"
703-
:command command
704-
:buffer (current-buffer)
705-
:stderr (with-current-buffer
706-
(get-buffer-create bdx-stderr-buffer)
707-
(goto-char (point-max))
708-
(let ((inhibit-read-only t))
709-
(insert "\n\n"))
710-
(current-buffer))
711-
:sentinel
712-
(lambda (proc _status)
713-
(let ((code (process-exit-status proc)))
714-
(unless (eq 0 code)
715-
(with-current-buffer (process-buffer proc)
716-
(insert
717-
(format
718-
"error: Disassembly process failed with code %s"
719-
code))))))))
720-
(while (accept-process-output process))
725+
(bdx--run-sync-process args)
721726

722727
(run-hooks 'bdx-disassembly-hook)
723728

@@ -836,18 +841,16 @@ If SYMBOL-PLIST is the symbol \\='interactive, then prompt for the symbol."
836841
(list (bdx-query "Find definition: " :require-match t
837842
:action #'bdx-find-definition))
838843
(pcase-let (((map :name :path :section) symbol-plist))
839-
(let ((command
840-
(apply #'bdx--command "find-definition"
841-
(append (list "-n" "1")
842-
(list
843-
(and name (format "fullname:\"%s\"" name))
844-
(and path (format "path:\"%s\"" path))
845-
(and section
846-
(format "section:\"%s\"" section))))))
844+
(let ((args
845+
(append '("find-definition" "-n" "1")
846+
(list
847+
(and name (format "fullname:\"%s\"" name))
848+
(and path (format "path:\"%s\"" path))
849+
(and section
850+
(format "section:\"%s\"" section)))))
847851
file line sym)
848852
(with-temp-buffer
849-
(apply #'call-process (car command)
850-
nil (current-buffer) nil (cdr command))
853+
(bdx--run-sync-process args)
851854

852855
(goto-char (point-min))
853856
(if (looking-at "^\\(.*\\):\\([0-9]+\\): \\(.*\\)")

0 commit comments

Comments
 (0)