From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: [jidanni@jidanni.org: ffap: if file at point doesn't exist, but its directory does] Date: Wed, 17 Feb 2004 23:09:46 +0200 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87lln11c51.fsf@mail.jurta.org> References: <87ad3i667c.fsf@mail.jurta.org> <40318CC7.90001@gnu.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1077063913 16599 80.91.224.253 (18 Feb 2004 00:25:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 18 Feb 2004 00:25:13 +0000 (UTC) Cc: jidanni@jidanni.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Feb 18 01:25:05 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AtFWT-0005lk-00 for ; Wed, 18 Feb 2004 01:25:05 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AtFWS-0006yr-00 for ; Wed, 18 Feb 2004 01:25:04 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AtFSI-00019c-Jy for emacs-devel@quimby.gnus.org; Tue, 17 Feb 2004 19:20:46 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AtFR0-0000se-3Q for emacs-devel@gnu.org; Tue, 17 Feb 2004 19:19:26 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AtFQS-0000hu-Q7 for emacs-devel@gnu.org; Tue, 17 Feb 2004 19:19:23 -0500 Original-Received: from [66.33.219.6] (helo=knife.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AtFQR-0000gp-Sh; Tue, 17 Feb 2004 19:18:51 -0500 Original-Received: from mail.jurta.org (80-235-39-236-dsl.mus.estpak.ee [80.235.39.236]) by knife.dreamhost.com (Postfix) with ESMTP id BE45AE4039; Tue, 17 Feb 2004 16:18:46 -0800 (PST) Original-To: Rajesh Vaidheeswarran In-Reply-To: <40318CC7.90001@gnu.org> (Rajesh Vaidheeswarran's message of "Mon, 16 Feb 2004 22:38:47 -0500") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:20034 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:20034 Rajesh Vaidheeswarran writes: > I'll test it and check it in, if all is well. I noticed that the function `ffap-file-at-point' has some redundant code: the code for testing local filenames has two copies. I think one of them should be removed. The second copy might be needed only if the variable `name' is changed between the first copy and the second. But it's not so: after trying to strip off line numbers and shell prompts the name remains unchanged. I added also another useful feature: if filename has spaces then the user can select a region with full filename with spaces to help ffap to get filename from the buffer. 2004-02-17 Juri Linkov * ffap.el (ffap-string-at-point): Get string from active region. (ffap-file-at-point): Remove redundant code. Index: emacs/lisp/ffap.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/ffap.el,v retrieving revision 1.42 diff -c -r1.42 ffap.el *** emacs/lisp/ffap.el 25 Dec 2003 17:44:48 -0000 1.42 --- emacs/lisp/ffap.el 17 Feb 2004 19:05:14 -0000 *************** *** 966,971 **** --- 966,973 ---- MODE (defaults to value of `major-mode') is a symbol used to look up string syntax parameters in `ffap-string-at-point-mode-alist'. If MODE is not found, we use `file' instead of MODE. + Get string from the region if region is active. This is useful + to help ffap to find file names with spaces. Sets `ffap-string-at-point' and `ffap-string-at-point-region'." (let* ((args (cdr *************** *** 973,987 **** (assq 'file ffap-string-at-point-mode-alist)))) (pt (point)) (str ! (buffer-substring ! (save-excursion ! (skip-chars-backward (car args)) ! (skip-chars-forward (nth 1 args) pt) ! (setcar ffap-string-at-point-region (point))) ! (save-excursion ! (skip-chars-forward (car args)) ! (skip-chars-backward (nth 2 args) pt) ! (setcar (cdr ffap-string-at-point-region) (point)))))) (set-text-properties 0 (length str) nil str) (setq ffap-string-at-point str))) --- 975,993 ---- (assq 'file ffap-string-at-point-mode-alist)))) (pt (point)) (str ! (if (and transient-mark-mode mark-active) ! (buffer-substring ! (setcar ffap-string-at-point-region (region-beginning)) ! (setcar (cdr ffap-string-at-point-region) (region-end))) ! (buffer-substring ! (save-excursion ! (skip-chars-backward (car args)) ! (skip-chars-forward (nth 1 args) pt) ! (setcar ffap-string-at-point-region (point))) ! (save-excursion ! (skip-chars-forward (car args)) ! (skip-chars-backward (nth 2 args) pt) ! (setcar (cdr ffap-string-at-point-region) (point))))))) (set-text-properties 0 (length str) nil str) (setq ffap-string-at-point str))) *************** *** 1128,1136 **** ((and ffap-shell-prompt-regexp (not abs) (string-match ffap-shell-prompt-regexp name) (ffap-file-exists-string (substring name (match-end 0))))) - ;; Immediately test local filenames. If default-directory is - ;; remote, you probably already have a connection. - ((and (not abs) (ffap-file-exists-string name))) ;; Accept remote names without actual checking (too slow): ((if abs (ffap-file-remote-p name) --- 1134,1139 ---- -- http://www.jurta.org/emacs/