From: Kelly Dean <kellydeanch@yahoo.com>
To: emacs-devel@gnu.org
Subject: [PATCH] Push mark before jumping to new location in a source code file from help page xref
Date: Sun, 2 Dec 2012 12:18:27 -0800 (PST) [thread overview]
Message-ID: <1354479507.68350.YahooMailClassic@web141105.mail.bf1.yahoo.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 286 bytes --]
When following a link in the help page for a function or variable to open the source code file, and the file is already open, it moves the point in that buffer, but it doesn't push the mark first, so I lose my previous place. It should push the mark first.
The attached patch fixes it.
[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 3183 bytes --]
--- emacs-24.2/lisp/help-mode.el
+++ emacs-24.2/lisp/help-mode.el
@@ -195,11 +195,15 @@
(help-C-file-name (indirect-function fun) 'fun)))
;; Don't use find-function-noselect because it follows
;; aliases (which fails for built-in functions).
- (let ((location
+ (let* (help-xref-target-buffer-preexisting
+ (location
(find-function-search-for-symbol fun nil file)))
(pop-to-buffer (car location))
(if (cdr location)
- (goto-char (cdr location))
+ (progn (if (and (/= (cdr location) (point))
+ help-xref-target-buffer-preexisting)
+ (push-mark))
+ (goto-char (cdr location)))
(message "Unable to find location in file"))))
'help-echo (purecopy "mouse-2, RET: find function's definition"))
@@ -224,10 +228,14 @@
'help-function (lambda (var &optional file)
(when (eq file 'C-source)
(setq file (help-C-file-name var 'var)))
- (let ((location (find-variable-noselect var file)))
+ (let* (help-xref-target-buffer-preexisting
+ (location (find-variable-noselect var file)))
(pop-to-buffer (car location))
(if (cdr location)
- (goto-char (cdr location))
+ (progn (if (and (/= (cdr location) (point))
+ help-xref-target-buffer-preexisting)
+ (push-mark))
+ (goto-char (cdr location)))
(message "Unable to find location in file"))))
'help-echo (purecopy "mouse-2, RET: find variable's definition"))
--- emacs-24.2/lisp/emacs-lisp/find-func.el
+++ emacs-24.2/lisp/emacs-lisp/find-func.el
@@ -211,7 +211,9 @@
(setq fun-or-var (find-function-advised-original
(indirect-function
(find-function-advised-original fun-or-var)))))
- (with-current-buffer (find-file-noselect file)
+ (if (boundp help-xref-target-buffer-preexisting)
+ (setq help-xref-target-buffer-preexisting (find-buffer-visiting file)))
+ (with-current-buffer (find-file-noselect file) (save-excursion
(goto-char (point-min))
(unless (re-search-forward
(if type
@@ -223,7 +225,7 @@
"\""))
nil t)
(error "Can't find source for %s" fun-or-var))
- (cons (current-buffer) (match-beginning 0))))
+ (cons (current-buffer) (match-beginning 0)))))
;;;###autoload
(defun find-library (library)
@@ -282,7 +284,9 @@
(setq library (substring library 0 (match-beginning 1))))
(let* ((filename (find-library-name library))
(regexp-symbol (cdr (assq type find-function-regexp-alist))))
- (with-current-buffer (find-file-noselect filename)
+ (if (boundp help-xref-target-buffer-preexisting)
+ (setq help-xref-target-buffer-preexisting (find-buffer-visiting filename)))
+ (with-current-buffer (find-file-noselect filename) (save-excursion
(let ((regexp (format (symbol-value regexp-symbol)
;; Entry for ` (backquote) macro in loaddefs.el,
;; (defalias (quote \`)..., has a \ but
@@ -310,7 +314,7 @@
(progn
(beginning-of-line)
(cons (current-buffer) (point)))
- (cons (current-buffer) nil))))))))
+ (cons (current-buffer) nil)))))))))
;;;###autoload
(defun find-function-noselect (function &optional lisp-only)
reply other threads:[~2012-12-02 20:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354479507.68350.YahooMailClassic@web141105.mail.bf1.yahoo.com \
--to=kellydeanch@yahoo.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).