aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Gutov2015-05-04 18:09:33 +0300
committerDmitry Gutov2015-05-04 18:51:48 +0300
commit14c1d2106cc770581d16a695734eb56e7b9662f2 (patch)
tree54563a8e74e033b1a0564412b272b296604004c1
parent9d4eaff316fffc00fecb2dc1b655bc0df6953144 (diff)
downloademacs-14c1d2106cc770581d16a695734eb56e7b9662f2.tar.gz
emacs-14c1d2106cc770581d16a695734eb56e7b9662f2.zip
Add xref-pulse-on-jump
* lisp/cedet/pulse.el (pulse-momentary-highlight-one-line): Add autoload cookie. * lisp/progmodes/xref.el (xref-pulse-on-jump): New option. (xref--maybe-pulse): New function. (xref-pop-marker-stack, xref--pop-to-location) (xref--display-position): Use it. (xref--location-at-point): Use back-to-indentation.
-rw-r--r--lisp/cedet/pulse.el1
-rw-r--r--lisp/progmodes/xref.el21
2 files changed, 18 insertions, 4 deletions
diff --git a/lisp/cedet/pulse.el b/lisp/cedet/pulse.el
index 89d44c20a6f..59fd5188643 100644
--- a/lisp/cedet/pulse.el
+++ b/lisp/cedet/pulse.el
@@ -224,6 +224,7 @@ Optional argument FACE specifies the face to do the highlighting."
224 ;; Remove this hook. 224 ;; Remove this hook.
225 (remove-hook 'pre-command-hook 'pulse-momentary-unhighlight)) 225 (remove-hook 'pre-command-hook 'pulse-momentary-unhighlight))
226 226
227;;;###autoload
227(defun pulse-momentary-highlight-one-line (point &optional face) 228(defun pulse-momentary-highlight-one-line (point &optional face)
228 "Highlight the line around POINT, unhighlighting before next command. 229 "Highlight the line around POINT, unhighlighting before next command.
229Optional argument FACE specifies the face to do the highlighting." 230Optional argument FACE specifies the face to do the highlighting."
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index b972bf28a78..a73085f825d 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -285,6 +285,11 @@ or when the command has been called with the prefix argument."
285 (const :tag "auto" nil)) 285 (const :tag "auto" nil))
286 :version "25.1") 286 :version "25.1")
287 287
288(defcustom xref-pulse-on-jump t
289 "When non-nil, momentarily highlight jump locations."
290 :type 'boolean
291 :version "25.1")
292
288(defvar xref--marker-ring (make-ring xref-marker-ring-length) 293(defvar xref--marker-ring (make-ring xref-marker-ring-length)
289 "Ring of markers to implement the marker stack.") 294 "Ring of markers to implement the marker stack.")
290 295
@@ -303,7 +308,12 @@ or when the command has been called with the prefix argument."
303 (switch-to-buffer (or (marker-buffer marker) 308 (switch-to-buffer (or (marker-buffer marker)
304 (error "The marked buffer has been deleted"))) 309 (error "The marked buffer has been deleted")))
305 (goto-char (marker-position marker)) 310 (goto-char (marker-position marker))
306 (set-marker marker nil nil)))) 311 (set-marker marker nil nil)
312 (xref--maybe-pulse))))
313
314(defun xref--maybe-pulse ()
315 (when xref-pulse-on-jump
316 (pulse-momentary-highlight-one-line (point))))
307 317
308;; etags.el needs this 318;; etags.el needs this
309(defun xref-clear-marker-stack () 319(defun xref-clear-marker-stack ()
@@ -338,7 +348,8 @@ WINDOW controls how the buffer is displayed:
338 (cl-ecase window 348 (cl-ecase window
339 ((nil) (switch-to-buffer (current-buffer))) 349 ((nil) (switch-to-buffer (current-buffer)))
340 (window (pop-to-buffer (current-buffer) t)) 350 (window (pop-to-buffer (current-buffer) t))
341 (frame (let ((pop-up-frames t)) (pop-to-buffer (current-buffer) t))))) 351 (frame (let ((pop-up-frames t)) (pop-to-buffer (current-buffer) t))))
352 (xref--maybe-pulse))
342 353
343 354
344;;; XREF buffer (part of the UI) 355;;; XREF buffer (part of the UI)
@@ -374,6 +385,7 @@ Used for temporary buffers.")
374 (with-selected-window (display-buffer (current-buffer) other-window) 385 (with-selected-window (display-buffer (current-buffer) other-window)
375 (goto-char pos) 386 (goto-char pos)
376 (recenter recenter-arg) 387 (recenter recenter-arg)
388 (xref--maybe-pulse)
377 (let ((buf (current-buffer)) 389 (let ((buf (current-buffer))
378 (win (selected-window))) 390 (win (selected-window)))
379 (with-current-buffer xref-buf 391 (with-current-buffer xref-buf
@@ -415,7 +427,9 @@ Used for temporary buffers.")
415 (xref-show-location-at-point)) 427 (xref-show-location-at-point))
416 428
417(defun xref--location-at-point () 429(defun xref--location-at-point ()
418 (get-text-property (point) 'xref-location)) 430 (save-excursion
431 (back-to-indentation)
432 (get-text-property (point) 'xref-location)))
419 433
420(defvar-local xref--window nil 434(defvar-local xref--window nil
421 "ACTION argument to call `display-buffer' with.") 435 "ACTION argument to call `display-buffer' with.")
@@ -423,7 +437,6 @@ Used for temporary buffers.")
423(defun xref-goto-xref () 437(defun xref-goto-xref ()
424 "Jump to the xref on the current line and bury the xref buffer." 438 "Jump to the xref on the current line and bury the xref buffer."
425 (interactive) 439 (interactive)
426 (back-to-indentation)
427 (let ((loc (or (xref--location-at-point) 440 (let ((loc (or (xref--location-at-point)
428 (user-error "No reference at point"))) 441 (user-error "No reference at point")))
429 (window xref--window)) 442 (window xref--window))