[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ggtags a2906b7 4/9: Allow `ggtags-global-output` to run
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ggtags a2906b7 4/9: Allow `ggtags-global-output` to run the process synchronously |
Date: |
Fri, 26 Mar 2021 22:46:20 -0400 (EDT) |
branch: externals/ggtags
commit a2906b7a35aa66c3c8e931155b20b8c0afc00887
Author: Nathaniel Nicandro <nathanielnicandro@gmail.com>
Commit: Leo Liu <sdl.web@gmail.com>
Allow `ggtags-global-output` to run the process synchronously
This will be useful when developing more frontends to ggtags which may need
to
receive a list of tag matches synchronously, such as XREF. Alternatively, a
separate function which calls a process synchronously using something like
`process-file` could be written, but then the ability to cancel the
subprocess
after a certain number of lines have been read would be lost. This is
important, for example, when asking Global for all references to a tag which
could have thousands of matches. Packages such as XREF cannot handle such a
large number of matches efficiently at the moment.
---
ggtags.el | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/ggtags.el b/ggtags.el
index 7293a26..94dc62c 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -1971,9 +1971,10 @@ ggtags: history match invalid, jump to first match
instead")
(and buffer-file-name ggtags-update-on-save
(ggtags-update-tags-single buffer-file-name 'nowait))))
-(defun ggtags-global-output (buffer cmds callback &optional cutoff)
+(defun ggtags-global-output (buffer cmds callback &optional cutoff sync)
"Asynchronously pipe the output of running CMDS to BUFFER.
-When finished invoke CALLBACK in BUFFER with process exit status."
+When finished invoke CALLBACK in BUFFER with process exit status.
+If SYNC is non-nil, synchronously run CMDS and call CALLBACK."
(or buffer (error "Output buffer required"))
(when (get-buffer-process (get-buffer buffer))
;; Notice running multiple processes in the same buffer so that we
@@ -2001,11 +2002,16 @@ When finished invoke CALLBACK in BUFFER with process
exit status."
(when (memq (process-status proc) '(exit signal))
(with-current-buffer (process-buffer proc)
(set-process-buffer proc nil)
- (funcall callback (process-exit-status proc)))))))
+ (unwind-protect
+ (funcall callback (process-exit-status proc))
+ (process-put proc :callback-done t)))))))
(set-process-query-on-exit-flag proc nil)
(and cutoff (set-process-filter proc filter))
(set-process-sentinel proc sentinel)
- proc))
+ (process-put proc :callback-done nil)
+ (if sync (while (not (process-get proc :callback-done))
+ (accept-process-output proc 1))
+ proc)))
(cl-defun ggtags-fontify-code (code &optional (mode major-mode))
(cl-check-type mode function)
- [elpa] externals/ggtags updated (17a121a -> 1c43705), Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags a0809f5 1/9: Bump version and require Emacs >= 25, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags c737181 2/9: Fix #158: ggtags-fontify-code improvement suggestion, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags 8840213 3/9: Correctly set `process-mark` in `ggtags-global-output`, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags c536ec5 5/9: Cache number of lines from previous output in `ggtags-global-output`, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags 6696764 6/9: Use `count-lines` instead of `line-number-at-pos`, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags 2f538aa 7/9: Add xref support, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags 1c43705 9/9: Update docs to use `universal-ctags` instead of `exuberant-ctags`, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags 4d90000 8/9: Fix #163: properly construct the --nearness arg to global, Stefan Monnier, 2021/03/26
- [elpa] externals/ggtags a2906b7 4/9: Allow `ggtags-global-output` to run the process synchronously,
Stefan Monnier <=