[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 50ad176 1/2: Add xref-after-jump-hook and xref-afte
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] master 50ad176 1/2: Add xref-after-jump-hook and xref-after-return-hook |
Date: |
Sun, 19 Jul 2015 17:51:47 +0000 |
branch: master
commit 50ad176d2868a6bc622014ebe49b5bad45d0372c
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Add xref-after-jump-hook and xref-after-return-hook
* lisp/progmodes/xref.el (xref-after-jump-hook)
(xref-after-return-hook): New hooks.
(xref-pulse-on-jump): Remove, in favor of the above.
(xref-pulse-momentarily): Rename from xref--maybe-pulse.
(xref--pop-to-location, xref--display-position)
(xref-pop-marker-stack): Use the new hooks, as requested in
http://lists.gnu.org/archive/html/emacs-devel/2015-07/msg00213.html
---
lisp/progmodes/xref.el | 52 ++++++++++++++++++++++++------------------------
1 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 1caded0..8d9a782 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -253,8 +253,7 @@ backward."
(defcustom xref-marker-ring-length 16
"Length of the xref marker ring."
- :type 'integer
- :version "25.1")
+ :type 'integer)
(defcustom xref-prompt-for-identifier '(not xref-find-definitions
xref-find-definitions-other-window
@@ -274,13 +273,16 @@ elements is negated."
(set :menu-tag "command specific" :tag "commands"
:value (not)
(const :tag "Except" not)
- (repeat :inline t (symbol :tag "command"))))
- :version "25.1")
+ (repeat :inline t (symbol :tag "command")))))
-(defcustom xref-pulse-on-jump t
- "When non-nil, momentarily highlight jump locations."
- :type 'boolean
- :version "25.1")
+(defcustom xref-after-jump-hook '(recenter
+ xref-pulse-momentarily)
+ "Functions called after jumping to an xref."
+ :type 'hook)
+
+(defcustom xref-after-return-hook '(xref-pulse-momentarily)
+ "Functions called after returning to a pre-jump location."
+ :type 'hook)
(defvar xref--marker-ring (make-ring xref-marker-ring-length)
"Ring of markers to implement the marker stack.")
@@ -301,19 +303,18 @@ elements is negated."
(error "The marked buffer has been deleted")))
(goto-char (marker-position marker))
(set-marker marker nil nil)
- (xref--maybe-pulse))))
-
-(defun xref--maybe-pulse ()
- (when xref-pulse-on-jump
- (let (beg end)
- (save-excursion
- (back-to-indentation)
- (if (eolp)
- (setq beg (line-beginning-position)
- end (1+ (point)))
- (setq beg (point)
- end (line-end-position))))
- (pulse-momentary-highlight-region beg end 'next-error))))
+ (run-hooks 'xref-after-return-hook))))
+
+(defun xref-pulse-momentarily ()
+ (let (beg end)
+ (save-excursion
+ (back-to-indentation)
+ (if (eolp)
+ (setq beg (line-beginning-position)
+ end (1+ (point)))
+ (setq beg (point)
+ end (line-end-position))))
+ (pulse-momentary-highlight-region beg end 'next-error)))
;; etags.el needs this
(defun xref-clear-marker-stack ()
@@ -349,7 +350,7 @@ WINDOW controls how the buffer is displayed:
((nil) (switch-to-buffer (current-buffer)))
(window (pop-to-buffer (current-buffer) t))
(frame (let ((pop-up-frames t)) (pop-to-buffer (current-buffer) t))))
- (xref--maybe-pulse))
+ (run-hooks 'xref-after-jump-hook))
;;; XREF buffer (part of the UI)
@@ -380,12 +381,11 @@ Used for temporary buffers.")
(when (and restore (not (eq (car restore) 'same)))
(push (cons buf win) xref--display-history))))
-(defun xref--display-position (pos other-window recenter-arg xref-buf)
+(defun xref--display-position (pos other-window xref-buf)
;; Show the location, but don't hijack focus.
(with-selected-window (display-buffer (current-buffer) other-window)
(goto-char pos)
- (recenter recenter-arg)
- (xref--maybe-pulse)
+ (run-hooks 'xref-after-jump-hook)
(let ((buf (current-buffer))
(win (selected-window)))
(with-current-buffer xref-buf
@@ -404,7 +404,7 @@ Used for temporary buffers.")
(add-hook 'buffer-list-update-hook #'xref--mark-selected nil t)
(with-current-buffer xref-buf
(push buf xref--temporary-buffers))))
- (xref--display-position (point) t 1 xref-buf))
+ (xref--display-position (point) t xref-buf))
(user-error (message (error-message-string err)))))
(defun xref-show-location-at-point ()