emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: address@hidden: ffap: if file at point doesn't exist, but its direct


From: Juri Linkov
Subject: Re: address@hidden: ffap: if file at point doesn't exist, but its directory does]
Date: Wed, 17 Feb 2004 23:09:46 +0200
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Rajesh Vaidheeswarran <address@hidden> 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  <address@hidden>

        * 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/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]