commit 107f5ccefdc250b9d2edce0897063d9a0d131252
parent 0e66ba861919eaa7a01bac0ec984b862ce8e929f
Author: andsy10 <andsy1016@gmail.com>
Date: Wed, 21 Oct 2026 02:13:00 +0800
Add option to control symlink following behavior
Diffstat:
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/consult-symbol.el b/consult-symbol.el
@@ -25,6 +25,13 @@
(?a . "Face"))
"Narrowing configuration for `consult-symbol'.")
+(defcustom consult-symbol-follow-symlinks t
+ "What to do if visiting a symbolic link to a source file under version control."
+ :type '(choice (const :tag "Ask for confirmation" ask)
+ (const :tag "Visit link and warn" nil)
+ (const :tag "Follow link" t))
+ :safe #'null)
+
(defun consult-symbol--type (sym)
"Return the narrowing type character of SYM."
(cond
@@ -121,16 +128,17 @@ source cannot be located are not previewed."
(if (not file)
(message "Unknown source location of `%s'" sym)
(xref-push-marker-stack)
- (pcase-let ((`(,buf . ,pos)
- (find-function-search-for-symbol sym type file)))
- (switch-to-buffer buf)
- (consult--jump
- (save-excursion
- (save-restriction
- (widen)
- (goto-char (or pos (point-min)))
- (point-marker)))))
- (run-hooks 'find-function-after-hook))))
+ (let ((vc-follow-symlinks consult-symbol-follow-symlinks))
+ (pcase-let ((`(,buf . ,pos)
+ (find-function-search-for-symbol sym type file)))
+ (switch-to-buffer buf)
+ (consult--jump
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char (or pos (point-min)))
+ (point-marker)))))
+ (run-hooks 'find-function-after-hook)))))
;;;###autoload
(defun consult-symbol ()