bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: It is prompting me for a filename. I would like to fill in the curre


From: Jeff Dwork
Subject: Re: It is prompting me for a filename. I would like to fill in the current filename.
Date: Tue, 23 Apr 2002 15:03:55 -0700

I wrote this many years ago.  It never made it into the elisp
archives, but it is in Google's gnu.emacs.sources archive as
"mini-ibfn.el".  I just tested it on emacs 21.1 and it still works.

It's short, so I'll include it here:

;;; mini-ibfn.el --- insert buffer-file-name (with or without directory) into 
minibuffer.

;; Copyright (C) 1994 Jeff Dwork.

;; Author: Jeff Dwork <address@hidden>
;; Version: 1.00
;; Date: 06-Nov-94

;;; This file is not part of GNU Emacs.

;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2, or (at your option)
;;; any later version.

;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.

;;; You should have received a copy of the GNU General Public License
;;; along with GNU Emacs; see the file COPYING.  If not, write to
;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

;;; Commentary:

;; Purpose:
;;
;; To provide a quick way to insert the current buffer-file-name into
;; the minibuffer.  If the current buffer is a dired buffer, inserts
;; the filename point is on.
;;
;; Very useful for finding related files, doing copies or renames, etc.
;;

;; Installation:
;; 
;; Put this file somewhere where Emacs can find it (i.e., in one of the paths
;; in your `load-path'), `byte-compile-file' it, and put something like this
;; in your ~/.emacs:
;;
;;   (load "mini-ibfn" nil t)
;;   (define-key minibuffer-local-map "\C-c\C-f" 
'minibuffer-ins-buffer-file-name)
;;   (define-key minibuffer-local-ns-map "\C-c\C-f" 
'minibuffer-ins-buffer-file-name)
;;   (define-key minibuffer-local-completion-map "\C-c\C-f" 
'minibuffer-ins-buffer-file-name)
;;   (define-key minibuffer-local-must-match-map "\C-c\C-f" 
'minibuffer-ins-buffer-file-name)
;;
;; minibuffer-ins-buffer-file-name has been tested on FSF Emacs 18.59 and 19.28.
;;

;; Feedback:
;;
;; Please send me bug reports, bug fixes, and extensions, so that I can
;; merge them into the master source.
;;     - Jeff Dwork (address@hidden)

;; History:
;;
;; Based on code from Pete Halverson and Piet van Oostrum
;;

(defun minibuffer-ins-buffer-file-name (arg)
  "Insert the non-dir file name of the current buffer into the minibuffer.
Insert full file name if called with arg.  If current buffer is in dired-mode,
insert filename point is on."
  (interactive "P")
  ;; We assume that the first entry in the buffer list with a non-nil
  ;; buffer-file-name or which is in dired-mode is the "real" current buffer,
  ;; since "(current-buffer)" just returns the minibuffer we're in.
  (let ((cbf (cdr (buffer-list))) b-f-name in-dired-mode)
    (while (and cbf (not (or 
                           (setq b-f-name (buffer-file-name (car cbf)))
                           (save-excursion
                             (set-buffer (car cbf))
                             (if (eq major-mode 'dired-mode)
                                 (setq in-dired-mode t))))))
      (setq cbf (cdr cbf)))
    (if (or b-f-name in-dired-mode)
        (progn
          (if in-dired-mode
              (save-excursion
                (set-buffer (car cbf))
                (setq b-f-name (dired-get-filename))))
          (if arg
              (insert b-f-name)
              (insert (file-name-nondirectory b-f-name))))
        (beep))))

;; end of mini-ibfn.el


Dan Jacobson writes:
 > To: address@hidden
 > Subject: Re: It is prompting me for a filename. I would like to fill in
 >  the current filename.
 > Date: 10 Apr 2002 15:28:47 +0800
 > 
 > And there it was, on M-n.  That means I wasted all your times.
 > Sorry.  Maybe I did M-p M-p M-p M-n M-n so thought I checked all
 > around not thinking that it was hiding on the first M-n.
 > 
...
 > 
 > Anyways, M-n will blot out anything else that you have typed in
 > already on that line in the minibuffer.  Also it isn't a general
 > solution in case we aren't in the minibuffer.
 > -- 
 > http://jidanni.org/ Taiwan(04)25854780
 > 
 > _______________________________________________
 > Bug-gnu-emacs mailing list
 > address@hidden
 > http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs

-- 
Jeff Dwork                      |           address@hidden
Advanced Micro Devices, M/S 45  | 408-749-5216 (voice) 408-774-8448 (fax)
PO Box 3453                     |----------------------------------------
Sunnyvale, Ca 94088-3453        | 





reply via email to

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