From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: Re: make ffap wildcard-friendly Date: Wed, 01 Dec 2004 22:11:15 +0200 Organization: JURTA Message-ID: <87fz2ppyn2.fsf@jurta.org> References: <3169k4F36frb2U1@individual.net> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1101932084 28539 80.91.229.6 (1 Dec 2004 20:14:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 1 Dec 2004 20:14:44 +0000 (UTC) Cc: ihs_4664@yahoo.com, jidanni@jidanni.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 01 21:14:39 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CZas2-0008G4-00 for ; Wed, 01 Dec 2004 21:14:39 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CZb1Y-0005Bt-KN for geb-bug-gnu-emacs@m.gmane.org; Wed, 01 Dec 2004 15:24:28 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CZb1X-0005Bg-IX for bug-gnu-emacs@gnu.org; Wed, 01 Dec 2004 15:24:27 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CZb1W-0005BG-Ki for bug-gnu-emacs@gnu.org; Wed, 01 Dec 2004 15:24:27 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CZb1W-0005Az-A9 for bug-gnu-emacs@gnu.org; Wed, 01 Dec 2004 15:24:26 -0500 Original-Received: from [66.33.219.6] (helo=knife.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CZarg-0004Ck-Bk for bug-gnu-emacs@gnu.org; Wed, 01 Dec 2004 15:14:17 -0500 Original-Received: from mail.jurta.org (80-235-32-92-dsl.mus.estpak.ee [80.235.32.92]) by knife.dreamhost.com (Postfix) with ESMTP id A6913E41B1; Wed, 1 Dec 2004 12:14:12 -0800 (PST) Original-To: bug-gnu-emacs@gnu.org In-Reply-To: <3169k4F36frb2U1@individual.net> (Kevin Rodgers's message of "Wed, 01 Dec 2004 09:25:36 -0700") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:9895 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:9895 Kevin Rodgers writes: > Dan Jacobson wrote: >> (setq ffap-dired-wildcards "[*?][^/]*\\'") should be the default. >> Hmm, the docstring doesn't say what if then there really is a filename >> with those... > > And the comment in the code confirms that is one of the reasons it is > disabled by default: > > ;; Suggestion from RHOGEE, 07 Jul 1994. Disabled, dired is still > ;; available by "C-x C-d ", and valid filenames may > ;; sometimes contain wildcard characters. `find-file' can expand wildcards, so it makes sense to call `find-file' with WILDCARDS argument instead of `dired'. So I think the following patch will do the right thing: C-x C-f (find-file-at-point) works like `find-file' wrt wildcards, and C-x d (dired-at-point) calls `dired' with wildcards. It contains also fixes to copy correctly all wildcards to the minibuffer. Index: lisp/ffap.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/ffap.el,v retrieving revision 1.45 diff -c -r1.45 ffap.el *** lisp/ffap.el 9 Jun 2004 18:32:06 -0000 1.45 --- lisp/ffap.el 1 Dec 2004 20:02:14 -0000 *************** *** 202,214 **** ;; through this section for features that you like, put an appropriate ;; enabler in your .emacs file. ! (defcustom ffap-dired-wildcards nil ! ;; Suggestion from RHOGEE, 07 Jul 1994. Disabled, dired is still ! ;; available by "C-x C-d ", and valid filenames may ! ;; sometimes contain wildcard characters. "*A regexp matching filename wildcard characters, or nil. If `find-file-at-point' gets a filename matching this pattern, ! it passes it on to `dired' instead of `find-file'." :type '(choice (const :tag "Disable" nil) (const :tag "Enable" "[*?][^/]*\\'") ;; regexp -- probably not useful --- 202,218 ---- ;; through this section for features that you like, put an appropriate ;; enabler in your .emacs file. ! (defcustom ffap-dired-wildcards "[*?][^/]*\\'" "*A regexp matching filename wildcard characters, or nil. + If `find-file-at-point' gets a filename matching this pattern, ! it passes it on to `find-file' with non-nil WILDCARDS argument, ! which expands wildcards and visits multiple files. To visit ! a file whose name contains wildcard characters you can suppress ! wildcard expansion by setting `find-file-wildcards'. ! ! If `dired-at-point' gets a filename matching this pattern, ! it passes it on to `dired'." :type '(choice (const :tag "Disable" nil) (const :tag "Enable" "[*?][^/]*\\'") ;; regexp -- probably not useful *************** *** 939,945 **** ;; Slightly controversial decisions: ;; * strip trailing "@" and ":" ;; * no commas (good for latex) ! (file "--:$+<>@-Z_a-z~" "<@" "@>;.,!?:") ;; An url, or maybe a email/news message-id: (url "--:=&?$+@-Z_a-z~#,%;" "^A-Za-z0-9" ":;.,!?") ;; Find a string that does *not* contain a colon: --- 943,949 ---- ;; Slightly controversial decisions: ;; * strip trailing "@" and ":" ;; * no commas (good for latex) ! (file "--:$+<>@-Z_a-z~*?" "<@" "@>;.,!:") ;; An url, or maybe a email/news message-id: (url "--:=&?$+@-Z_a-z~#,%;" "^A-Za-z0-9" ":;.,!?") ;; Find a string that does *not* contain a colon: *************** *** 1187,1192 **** --- 1191,1199 ---- remote-dir (substring name (match-end 1))))) (ffap-file-exists-string (ffap-replace-file-component remote-dir name)))))) + ((and ffap-dired-wildcards + (string-match ffap-dired-wildcards name) + name)) ;; Try all parent directories by deleting the trailing directory ;; name until existing directory is found or name stops changing ((let ((dir name)) *************** *** 1357,1366 **** ((ffap-url-p filename) (let (current-prefix-arg) ; w3 2.3.25 bug, reported by KPC (funcall ffap-url-fetcher filename))) - ;; This junk more properly belongs in a modified ffap-file-finder: ((and ffap-dired-wildcards ! (string-match ffap-dired-wildcards filename)) ! (dired filename)) ((or (not ffap-newfile-prompt) (file-exists-p filename) (y-or-n-p "File does not exist, create buffer? ")) --- 1364,1374 ---- ((ffap-url-p filename) (let (current-prefix-arg) ; w3 2.3.25 bug, reported by KPC (funcall ffap-url-fetcher filename))) ((and ffap-dired-wildcards ! (string-match ffap-dired-wildcards filename) ! (eq ffap-file-finder 'find-file) ! find-file-wildcards) ! (funcall ffap-file-finder (expand-file-name filename) t)) ((or (not ffap-newfile-prompt) (file-exists-p filename) (y-or-n-p "File does not exist, create buffer? ")) -- Juri Linkov http://www.jurta.org/emacs/