From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.bugs 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 Message-ID: <87txbj5vwi.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1393586295 5152 80.91.229.3 (28 Feb 2014 11:18:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 28 Feb 2014 11:18:15 +0000 (UTC) To: 16904@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Feb 28 12:18:23 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WJLSQ-0000L9-FW for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Feb 2014 12:18:22 +0100 Original-Received: from localhost ([::1]:50498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJLSQ-0005up-2g for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Feb 2014 06:18:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJLSG-0005oc-Ln for bug-gnu-emacs@gnu.org; Fri, 28 Feb 2014 06:18:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJLS6-0006wv-Hp for bug-gnu-emacs@gnu.org; Fri, 28 Feb 2014 06:18:12 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJLS6-0006wp-EF for bug-gnu-emacs@gnu.org; Fri, 28 Feb 2014 06:18:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WJLS6-0002lE-8I for bug-gnu-emacs@gnu.org; Fri, 28 Feb 2014 06:18:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 28 Feb 2014 11:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 16904 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.139358627210588 (code B ref -1); Fri, 28 Feb 2014 11:18:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Feb 2014 11:17:52 +0000 Original-Received: from localhost ([127.0.0.1]:43675 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WJLRv-0002ki-Ju for submit@debbugs.gnu.org; Fri, 28 Feb 2014 06:17:52 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44284) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WJLRs-0002kR-BR for submit@debbugs.gnu.org; Fri, 28 Feb 2014 06:17:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJLRg-0006rJ-Iz for submit@debbugs.gnu.org; Fri, 28 Feb 2014 06:17:42 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:38637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJLRg-0006rF-G4 for submit@debbugs.gnu.org; Fri, 28 Feb 2014 06:17:36 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJLRa-0005SU-Fl for bug-gnu-emacs@gnu.org; Fri, 28 Feb 2014 06:17:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJLRR-0006lW-QF for bug-gnu-emacs@gnu.org; Fri, 28 Feb 2014 06:17:30 -0500 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:37018) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJLRR-0006kG-Hm for bug-gnu-emacs@gnu.org; Fri, 28 Feb 2014 06:17:21 -0500 Original-Received: from compute2.internal (compute2.nyi.mail.srv.osa [10.202.2.42]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 126262113D for ; Fri, 28 Feb 2014 06:17:20 -0500 (EST) Original-Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Fri, 28 Feb 2014 06:17:20 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=from:to:subject:date:message-id:mime-version:content-type; s= mesmtp; bh=hggOcKLwOtxZIZnxbibz6TrWtoI=; b=t5luWc9Ckx/0+oTHGvvzt ys/xrUtbZkbbUcdrSI/Hrr40DR/EcCBc89GJdq/gjbFU8qPRAl6Yiib8Fp7kpq/3 CEFmkWzgNQAU8pDhX47TbcSUjtw6ZHtS7/P/aZYGqDe2vxpqqqH0Ch3mWpY3gg9L HfETcjbmqoHlojDyvWrOpU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id :mime-version:content-type; s=smtpout; bh=hggOcKLwOtxZIZnxbibz6T rWtoI=; b=n0/rs2/PhXnz6QlCa4FYoqfTdpie1Nuu8O1oFL1uGdMVfnJjKT3IEy /Y8m/WvJJ7tEIZlaMCU5Y5MelNK4cWjW0mmOVpvAXMuAjR/GMn6IuR9u+LKa42QR LZ7kcrvZHhxcYn8JrERLy8OOg1skk+xraOSiR9c+5mTVM/7azYyWQ= X-Sasl-enc: iKR9mIh6tUMH0ztlMRehEPOaJhQo0nqVejiupIQYhiQH 1393586239 Original-Received: from shorty.local (unknown [23.243.199.75]) by mail.messagingengine.com (Postfix) with ESMTPA id CD429C00005 for ; Fri, 28 Feb 2014 06:17:19 -0500 (EST) Original-Received: from dima by shorty.local with local (Exim 4.80) (envelope-from ) id 1WJLRO-0006qS-DF for bug-gnu-emacs@gnu.org; Fri, 28 Feb 2014 03:17:18 -0800 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:86374 Archived-At: --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-find-file-functions-now-work-from-indirect-clone-buf.patch >From af44dfe3785c2e02f6216ecbbd15f484e1c6d8c1 Mon Sep 17 00:00:00 2001 From: Dima Kogan 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 --=-=-=--