* find-alternate-file from dired wildcard dir
@ 2002-04-11 17:47 Dan Jacobson
2002-04-12 16:07 ` Kevin Rodgers
0 siblings, 1 reply; 5+ messages in thread
From: Dan Jacobson @ 2002-04-11 17:47 UTC (permalink / raw)
find-alternate-file prompts with the current filename -- quite
helpful. However if it is in a dired wildcard directory, e,g, from C-x d
*.c then this doesn't work. The *.c isn't even available from M-n either.
--
http://jidanni.org/ Taiwan(04)25854780
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: find-alternate-file from dired wildcard dir
2002-04-11 17:47 find-alternate-file from dired wildcard dir Dan Jacobson
@ 2002-04-12 16:07 ` Kevin Rodgers
2002-04-12 18:18 ` Kevin Rodgers
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Rodgers @ 2002-04-12 16:07 UTC (permalink / raw)
Dan Jacobson wrote:
>
> find-alternate-file prompts with the current filename -- quite
> helpful. However if it is in a dired wildcard directory, e,g, from C-x d
> *.c then this doesn't work. The *.c isn't even available from M-n either.
Here's a workaround to make it available via `M-n':
(defadvice find-alternate-file (around dired-directory activate)
"Use `dired-directory' as `buffer-file-name' when called interactively."
(let ((buffer-file-name (and (interactive-p)
(stringp dired-directory)
dired-directory)))
ad-do-it))
To automatically insert it in the minibuffer, you'd have to copy the entire
9-line `interactive' form from files.el to the advice and add the same
buffer-file-name binding to its `let' form as above. But then you may as
well just modify files.el instead.
This doesn't handle the case where `dired-directory' is a list, which I
think only occurs when dired is called programmatically anyway.
--
Kevin Rodgers <kevinr@ihs.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: find-alternate-file from dired wildcard dir
2002-04-12 16:07 ` Kevin Rodgers
@ 2002-04-12 18:18 ` Kevin Rodgers
2002-04-16 4:20 ` insert current buffer name anywhere vs. M-p M-n Dan Jacobson
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Rodgers @ 2002-04-12 18:18 UTC (permalink / raw)
Kevin Rodgers wrote:
>
> Dan Jacobson wrote:
> >
> > find-alternate-file prompts with the current filename -- quite
> > helpful. However if it is in a dired wildcard directory, e,g, from C-x d
> > *.c then this doesn't work. The *.c isn't even available from M-n either.
>
> Here's a workaround to make it available via `M-n':
...
Sorry, that breaks find-alternate-file outside of Dired buffers:
(defadvice find-alternate-file (around dired-directory activate)
"In Dired, use `dired-directory' as `buffer-file-name' when called
interactively."
(let ((buffer-file-name (if (and (interactive-p)
(eq major-mode 'dired-mode)
(stringp dired-directory))
dired-directory
buffer-file-name)))
ad-do-it))
--
Kevin Rodgers <kevinr@ihs.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* insert current buffer name anywhere vs. M-p M-n
2002-04-12 18:18 ` Kevin Rodgers
@ 2002-04-16 4:20 ` Dan Jacobson
2002-04-16 10:22 ` Ehud Karni
0 siblings, 1 reply; 5+ messages in thread
From: Dan Jacobson @ 2002-04-16 4:20 UTC (permalink / raw)
>> > find-alternate-file prompts with the current filename -- quite
>> > helpful. However if it is in a dired wildcard directory, e,g, from C-x d
>> > *.c then this doesn't work. The *.c isn't even available from M-n either.
>>
>> Here's a workaround to make it available via `M-n':
K> Sorry, that breaks find-alternate-file outside of Dired buffers:
Anyways, all the more argument for a set of keybindings that can
insert the current file, or current file name, or dired file on line name, or
recent-file-excluding-minibuffer-itself name, at point. C-u for full
path. Wouldn't that save hacking all the different places it is
needed?
It could be integrated with C-x r register stuff, but care should be
taken that the keystrokes don't get too long.
--
http://jidanni.org/ Taiwan(04)25854780
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: insert current buffer name anywhere vs. M-p M-n
2002-04-16 4:20 ` insert current buffer name anywhere vs. M-p M-n Dan Jacobson
@ 2002-04-16 10:22 ` Ehud Karni
0 siblings, 0 replies; 5+ messages in thread
From: Ehud Karni @ 2002-04-16 10:22 UTC (permalink / raw)
Cc: bug-gnu-emacs, gnu-emacs-sources
On 16 Apr 2002 12:20:31 +0800, Dan Jacobson <jidanni@deadspam.com> wrote:
>
> Anyways, all the more argument for a set of keybindings that can
> insert the current file, or current file name, or dired file on line name, or
> recent-file-excluding-minibuffer-itself name, at point. C-u for full
> path. Wouldn't that save hacking all the different places it is
> needed?
>
> It could be integrated with C-x r register stuff, but care should be
> taken that the keystrokes don't get too long.
Here are some functions that can insert the current word, buffer name,
file name or directory name into the minibuf (as a bonus there is a
function for selecting from minibuf history). I think, I already posted
it to emacs.sources, but anyway here it is.
Ehud.
;;needed in insert-word-or-file-name
(defun backward-to-non-blank () "go to 1st non blank (after blank) to left"
(interactive)
(if (re-search-backward "[ \t\n][^ \t\n]" (point-min) t)
(forward-char 1)
(if (string-match "[^ \t\n]" (buffer-substring 1 2))
(goto-char (point-min)))))
;;needed in insert-buffer/file/dir-name functions
(defun buffer-name-not-mini ()
"Return the name of current buffer, as a string.
If current buffer is the *mini-buffer* return name of previous-window."
(buffer-name (if (window-minibuffer-p)
(if (eq (get-lru-window) (next-window))
(window-buffer (previous-window))
(window-buffer (next-window)))
nil)))
(defun insert-word-or-file-name ()
"copy word cursor is on or file name to minibuff input"
(interactive)
(let* ((bfl (current-buffer))
(str ""))
(set-buffer (buffer-name-not-mini))
(cond
((eq major-mode 'dired-mode)
(setq str (dired-get-filename t t)))
(t
(let (bch ech)
(forward-char 1)
(backward-to-non-blank)
(setq bch (point))
(re-search-forward "[^ \t\n][ \t\n]" (point-max) t)
(setq ech (1- (point)))
(setq str (buffer-substring bch ech)))))
(set-buffer bfl)
(insert str)))
(defun insert-buffer-name ()
"insert buffer name of current buffer or most recent buffer when in minibuffer"
(interactive)
(insert (buffer-name-not-mini)))
(defun insert-buffer-dir-name ()
"insert dir name of current buffer or most recent buffer when in minibuffer"
(interactive)
(let* ((bfn (buffer-file-name (get-buffer (buffer-name-not-mini)))))
(if bfn
(insert (file-name-directory bfn)))))
(defun insert-buffer-file-name ()
"insert file name of current buffer or most recent buffer when in minibuffer"
(interactive)
(let* ((bfn (buffer-file-name (get-buffer (buffer-name-not-mini)))))
(if bfn
(insert (file-name-nondirectory bfn)))))
(defun complete-from-minibuffer-history ()
"Take the history list and make it available as a `completions' buffer"
(interactive)
(with-output-to-temp-buffer "*Completions*"
(display-completion-list (symbol-value minibuffer-history-variable))
(save-excursion
(set-buffer standard-output)
(setq completion-base-size 0))))
(defun insert-current-date-time-minibuf ()
"insert the current date and time into mini-buffer."
(interactive)
(insert (format-time-string "%y%m%d_%H%M%S" (current-time))))
(defun keymap-test (var) ; internal function for keymap checking
(and (boundp var)
(keymapp (symbol-value var))))
(let ((minimaps (apropos-internal "mini" 'keymap-test))
map op)
(while minimaps
(setq map (symbol-value (car minimaps)))
(setq minimaps (cdr minimaps))
(setq op (lookup-key map [9])) ;tab char (^I)
(if op
(define-key map '[tab] op))
(define-key map "\C-b" 'insert-buffer-name)
(define-key map "\C-d" 'insert-buffer-dir-name)
(define-key map "\C-f" 'insert-buffer-file-name)
(define-key map "\C-w" 'insert-word-or-file-name)
(define-key map "\C-t" 'insert-current-date-time-minibuf)
(define-key map "\eh" 'complete-from-minibuffer-history)))
--
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
mailto:ehud@unix.simonwiesel.co.il Better Safe Than Sorry
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-04-16 10:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-11 17:47 find-alternate-file from dired wildcard dir Dan Jacobson
2002-04-12 16:07 ` Kevin Rodgers
2002-04-12 18:18 ` Kevin Rodgers
2002-04-16 4:20 ` insert current buffer name anywhere vs. M-p M-n Dan Jacobson
2002-04-16 10:22 ` Ehud Karni
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.