all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [ffap.el] dired-at-point bug
@ 2004-02-19  4:57 Hiroshi Fujishima
  2004-02-23  3:55 ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Hiroshi Fujishima @ 2004-02-19  4:57 UTC (permalink / raw)


In emacs-21.3

M-x ffap-bindings and C-x d ~not-exest creates `~not-exest' directory.

In emacs-21.3.50 (after 2003-03-06)

M-x ffap-bindings and C-x d ~not-exest causes `Wrong type argument:
stringp, nil' error, because (file-name-directory "~not-exest") return
nil though file-writable-p() require string type argument.

2003-03-06  Kevin Rodgers  <kevin.rodgers@ihs.com>  (tiny change)

        * ffap.el (dired-at-point): Check whether the user can create a
        directory before asking about creating it.

Index: ffap.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ffap.el,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- ffap.el	15 Feb 2003 19:26:25 -0000	1.35
+++ ffap.el	6 Mar 2003 20:30:05 -0000	1.36
@@ -1,4 +1,4 @@
-;;; ffap.el --- find file (or url) at point
+;; ffap.el --- find file (or url) at point
 ;;
 ;; Copyright (C) 1995, 96, 97, 2000  Free Software Foundation, Inc.
 ;;
@@ -1658,7 +1658,8 @@
       (if (file-directory-p filename)
 	  (dired (expand-file-name filename))
 	(dired (concat (expand-file-name filename) "*"))))
-     ((y-or-n-p "Directory does not exist, create it? ")
+     ((and (file-writable-p (file-name-directory filename))
+           (y-or-n-p "Directory does not exist, create it? "))
       (make-directory filename)
       (dired filename))
      ((error "No such file or directory `%s'" filename)))))

-- 
Hiroshi Fujishima

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ffap.el] dired-at-point bug
  2004-02-19  4:57 [ffap.el] dired-at-point bug Hiroshi Fujishima
@ 2004-02-23  3:55 ` Juri Linkov
  2004-02-24  6:45   ` Hiroshi Fujishima
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2004-02-23  3:55 UTC (permalink / raw)
  Cc: emacs-devel

Hiroshi Fujishima <pooh@nature.tsukuba.ac.jp> writes:
> M-x ffap-bindings and C-x d ~not-exest causes `Wrong type argument:
> stringp, nil' error, because (file-name-directory "~not-exest") return
> nil though file-writable-p() require string type argument.

The patch below fixes this bug.

BTW, I have another problem with dired-at-point: its prompter deals
with local directories as with regular files.  It's very inconvenient.

For example, ("^" indicates the default point position in the minibuffer):

File: "/dir1/dir2"   Prompt: /dir1/^dir2
File: "/dir1/file"   Prompt: /dir1/^file

I fixed the dired prompter function so that it interprets directories
as a directory and gets a directory component from existing local files:

File: "/dir1/dir2"   Prompt: /dir1/dir2/^
File: "/dir1/file"   Prompt: /dir1/^

Index: emacs/lisp/ffap.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ffap.el,v
retrieving revision 1.43
diff -c -r1.43 ffap.el
*** emacs/lisp/ffap.el	21 Feb 2004 13:41:04 -0000	1.43
--- emacs/lisp/ffap.el	23 Feb 2004 02:59:30 -0000
***************
*** 1,7 ****
! ;; ffap.el --- find file (or url) at point
! ;;
! ;; Copyright (C) 1995, 96, 97, 2000  Free Software Foundation, Inc.
! ;;
  ;; Author: Michelangelo Grigni <mic@mathcs.emory.edu>
  ;; Maintainer: Rajesh Vaidheeswarran  <rv@gnu.org>
  ;; Created: 29 Mar 1993
--- 1,7 ----
! ;;; ffap.el --- find file (or url) at point
! 
! ;; Copyright (C) 1995, 96, 97, 2000, 2004  Free Software Foundation, Inc.
! 
  ;; Author: Michelangelo Grigni <mic@mathcs.emory.edu>
  ;; Maintainer: Rajesh Vaidheeswarran  <rv@gnu.org>
  ;; Created: 29 Mar 1993
***************
*** 1675,1681 ****
        (if (file-directory-p filename)
  	  (dired (expand-file-name filename))
  	(dired (concat (expand-file-name filename) "*"))))
!      ((and (file-writable-p (file-name-directory filename))
             (y-or-n-p "Directory does not exist, create it? "))
        (make-directory filename)
        (dired filename))
--- 1678,1686 ----
        (if (file-directory-p filename)
  	  (dired (expand-file-name filename))
  	(dired (concat (expand-file-name filename) "*"))))
!      ((and (file-writable-p
!             (or (file-name-directory (directory-file-name filename))
!                 filename))
             (y-or-n-p "Directory does not exist, create it? "))
        (make-directory filename)
        (dired filename))
***************
*** 1688,1696 ****
        (ffap-read-file-or-url
         (if ffap-url-regexp "Dired file or URL: " "Dired file: ")
         (prog1
! 	   (setq guess (or guess (ffap-guesser)))
! 	 (and guess (ffap-highlight))
! 	 ))
      (ffap-highlight t)))
  \f
  ;;; Offer default global bindings (`ffap-bindings'):
--- 1693,1716 ----
        (ffap-read-file-or-url
         (if ffap-url-regexp "Dired file or URL: " "Dired file: ")
         (prog1
! 	   (setq guess (or guess
!                            (let ((guess (ffap-guesser)))
!                              (if (or (not guess)
!                                      (ffap-url-p guess)
!                                      (ffap-file-remote-p guess))
!                                  guess
!                                (setq guess (abbreviate-file-name
!                                             (expand-file-name guess)))
!                                (cond
!                                 ;; interpret local directory as directory
!                                 ((file-directory-p guess)
!                                  (file-name-as-directory guess))
!                                 ;; get directory from local file
!                                 ((file-regular-p guess)
!                                  (file-name-directory guess))
!                                 (guess))))
!                            ))
! 	 (and guess (ffap-highlight))))
      (ffap-highlight t)))
  \f
  ;;; Offer default global bindings (`ffap-bindings'):

-- 
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ffap.el] dired-at-point bug
  2004-02-23  3:55 ` Juri Linkov
@ 2004-02-24  6:45   ` Hiroshi Fujishima
  0 siblings, 0 replies; 3+ messages in thread
From: Hiroshi Fujishima @ 2004-02-24  6:45 UTC (permalink / raw)
  Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:

>> M-x ffap-bindings and C-x d ~not-exest causes `Wrong type argument:
>> stringp, nil' error, because (file-name-directory "~not-exest") return
>> nil though file-writable-p() require string type argument.
>
> The patch below fixes this bug.

Thanks, It works for me.  Could you please install it in CVS?

-- 
Hiroshi Fujishima

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-02-24  6:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-19  4:57 [ffap.el] dired-at-point bug Hiroshi Fujishima
2004-02-23  3:55 ` Juri Linkov
2004-02-24  6:45   ` Hiroshi Fujishima

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.