all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: [ffap.el] dired-at-point bug
Date: Mon, 23 Feb 2004 05:55:19 +0200	[thread overview]
Message-ID: <87k72eh2rs.fsf@mail.jurta.org> (raw)
In-Reply-To: <7c7jyjr7i3.fsf@eyesore.nature.tsukuba.ac.jp> (Hiroshi Fujishima's message of "Thu, 19 Feb 2004 13:57:40 +0900")

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/

  reply	other threads:[~2004-02-23  3:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-19  4:57 [ffap.el] dired-at-point bug Hiroshi Fujishima
2004-02-23  3:55 ` Juri Linkov [this message]
2004-02-24  6:45   ` Hiroshi Fujishima

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k72eh2rs.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.