[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/backports-25.2 1cd6309 14/46: Allow ff-find-other-
From: |
Noam Postavsky |
Subject: |
[Emacs-diffs] scratch/backports-25.2 1cd6309 14/46: Allow ff-find-other-file (etc) to work with indirect clone buffers |
Date: |
Sun, 2 Oct 2016 14:04:48 +0000 (UTC) |
branch: scratch/backports-25.2
commit 1cd630976310eaa7f24009588be96fdfa45cf9b4
Author: Dima Kogan <address@hidden>
Commit: Noam Postavsky <address@hidden>
Allow ff-find-other-file (etc) to work with indirect clone buffers
* lisp/find-file.el (ff-buffer-file-name): New function to
allow the feature to work with indirect buffers, too
(bug#16904).
(ff-find-the-other-file): Use it.
(ff-other-file-name): Ditto.
(ff-get-file-name): Ditto.
(cherry picked from commit 70c3c79ec000bdf43d8558e0ee0fd8d8b8547245)
---
lisp/find-file.el | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/lisp/find-file.el b/lisp/find-file.el
index 8bd810f..3c3d860 100644
--- a/lisp/find-file.el
+++ b/lisp/find-file.el
@@ -378,6 +378,15 @@ Variables of interest include:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Support functions
+(defun ff-buffer-file-name (&optional buf)
+ "Like `buffer-file-name' but works with indirect buffers as well.
+If BUF is nil, uses the current buffer."
+ (unless buf
+ (setq buf (current-buffer)))
+ (or (buffer-file-name buf)
+ (when (buffer-base-buffer buf)
+ (buffer-file-name (buffer-base-buffer buf)))))
+
(defun ff-find-the-other-file (&optional in-other-window)
"Find the header or source file corresponding to the current file.
Being on a `#include' line pulls in that file, but see the help on
@@ -420,9 +429,7 @@ If optional IN-OTHER-WINDOW is non-nil, find the file in
another window."
(setq alist (if (symbolp ff-other-file-alist)
(symbol-value ff-other-file-alist)
ff-other-file-alist)
- pathname (if (buffer-file-name)
- (buffer-file-name)
- "/none.none"))
+ pathname (or (ff-buffer-file-name) "/none.none"))
(setq fname (file-name-nondirectory pathname)
no-match nil
@@ -448,7 +455,7 @@ If optional IN-OTHER-WINDOW is non-nil, find the file in
another window."
;; invoke it with the name of the current file
(if (and (atom action) (fboundp action))
(progn
- (setq suffixes (funcall action (buffer-file-name))
+ (setq suffixes (funcall action (ff-buffer-file-name))
match (cons (car match) (list suffixes))
stub nil
default-name (car suffixes)))
@@ -550,9 +557,7 @@ the `ff-ignore-include' variable."
(setq alist (if (symbolp ff-other-file-alist)
(symbol-value ff-other-file-alist)
ff-other-file-alist)
- pathname (if (buffer-file-name)
- (buffer-file-name)
- "/none.none"))
+ pathname (or (ff-buffer-file-name) "/none.none"))
(setq fname (file-name-nondirectory pathname)
match (car alist))
@@ -576,7 +581,7 @@ the `ff-ignore-include' variable."
;; invoke it with the name of the current file
(if (and (atom action) (fboundp action))
(progn
- (setq suffixes (funcall action (buffer-file-name))
+ (setq suffixes (funcall action (ff-buffer-file-name))
match (cons (car match) (list suffixes))
stub nil))
@@ -655,14 +660,14 @@ name of the first file found."
(message "Finding buffer %s..." filename))
(if (bufferp (get-file-buffer filename))
- (setq found (buffer-file-name (get-file-buffer filename))))
+ (setq found (ff-buffer-file-name (get-file-buffer filename))))
(setq blist (buffer-list))
(setq buf (buffer-name (car blist)))
(while (and blist (not found))
(if (string-match-p (concat filename "<[0-9]+>") buf)
- (setq found (buffer-file-name (car blist))))
+ (setq found (ff-buffer-file-name (car blist))))
(setq blist (cdr blist))
(setq buf (buffer-name (car blist))))
- [Emacs-diffs] scratch/backports-25.2 7d89389 04/46: Make erc connect asynchronously, (continued)
- [Emacs-diffs] scratch/backports-25.2 7d89389 04/46: Make erc connect asynchronously, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 0d9709e 19/46: Meta + shift + Fn combos are recognized by xterm>=216., Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 5266c11 13/46: Allow more shell script defun forms, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 fbe5f7b 11/46: Completely ignore buffers with no name when copying file names, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 70244eb 15/46: Allow highlighting things like @math{2^{12}}, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 95d5520 12/46: Allow optional parameter to be nil, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 0780aa5 16/46: Replace XXX acronyms with draft standard ones, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 5f4c54b 18/46: Declare $ as an expression prefix in SCSS, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 344bc2b 17/46: Strip out some leading whitespace when looking at logs, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 69e0e89 23/46: Handle auth-source items with special characters on OS X, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 1cd6309 14/46: Allow ff-find-other-file (etc) to work with indirect clone buffers,
Noam Postavsky <=
- [Emacs-diffs] scratch/backports-25.2 5c084d9 10/46: Remove spurious newline in package list, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 80cf0b6 21/46: Restore the fix to bug#18527 from commit d6868025, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 51656da 28/46: Fix number-at-point in lisp buffers, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 0876366 43/46: Fix back-white <-> black-white typo, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 f3a19cf 31/46: Make a menu less ambiguous, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 12d1955 41/46: * lisp/files.el (version-control): Drop :group vc (Bug #14687), Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 cf54324 42/46: Improve error when installing non-package dirs, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 9e9f7c8 45/46: Don't --load directories, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 eb5dd2c 46/46: Don't require isearch-update before isearch-done, Noam Postavsky, 2016/10/02
- [Emacs-diffs] scratch/backports-25.2 aad7ede 07/46: Ensure progress when fetching from the queue, Noam Postavsky, 2016/10/02