From: Dima Kogan <dima@secretsauce.net>
To: 16904@debbugs.gnu.org
Subject: bug#16904: 24.3; [PATCH] ff-find-other-file and friends now work with indirect clone buffers
Date: Fri, 28 Feb 2014 03:17:17 -0800 [thread overview]
Message-ID: <87txbj5vwi.fsf@secretsauce.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 168 bytes --]
Attached is a small patch that allows (ff-find-other-file) to work with
indirect clone buffers. All it does is to look at the base buffer if
(buffer-file-name) is nil
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-find-file-functions-now-work-from-indirect-clone-buf.patch --]
[-- Type: text/x-diff, Size: 3747 bytes --]
From af44dfe3785c2e02f6216ecbbd15f484e1c6d8c1 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@secretsauce.net>
Date: Fri, 28 Feb 2014 03:02:03 -0800
Subject: [PATCH] find-file functions now work from indirect clone buffers
---
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 f3a135a..5992454 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))))
--
1.9.0
next reply other threads:[~2014-02-28 11:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-28 11:17 Dima Kogan [this message]
2014-03-07 22:53 ` bug#16904: 24.3; [PATCH] ff-find-other-file and friends now work with indirect clone buffers Stefan Monnier
2014-03-08 2:23 ` Dima Kogan
2014-03-10 2:41 ` Stefan Monnier
2014-03-10 3:30 ` Dima Kogan
2014-03-10 5:00 ` Stefan Monnier
2016-02-24 3:02 ` Lars Ingebrigtsen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87txbj5vwi.fsf@secretsauce.net \
--to=dima@secretsauce.net \
--cc=16904@debbugs.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.