emacs-devel
[Top][All Lists]
Advanced

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

key to yank text at point into minibuffer?


From: Drew Adams
Subject: key to yank text at point into minibuffer?
Date: Sat, 11 Feb 2006 09:17:21 -0800

Perhaps something like this already exists and I'm unaware of it. If not,
perhaps it could be added - it represents a trivial change for users and
implementers. If users don't use it, then it means no change to them.

Some people use ffap.el. It tries to DTRT by placing some text at point
(with sometimes minor changes) into the minibuffer to serve as initial
input. It does this with file names, URLS, etc. in the buffer text.

I tried ffap.el for a while and found I didn't care much for it. In
particular, in Dired I rarely want to use the file name at point when I use
`C-x f' - if I want that then I just use `RET'.  Anyway, if people find
ffap.el handy that's fine. I realize that it also does other things,
including mailto: prefixing and remote-file handling.

Anyway, as a poor-man's replacement for some of the ffap functionality, I
added a minibuffer key (I use `M-.') to all minibuffer maps. This command
just yanks the symbol name at point into the minibuffer, replacing what was
there. It uses Emacs-Lisp symbol syntax, so, in practice, this also picks up
file names and URLs in the buffer. IOW, it provides some of what ffap
provides (the part I want), but without its DTRT second-guessing and only
upon demand (like setting `ffap-require-prefix' to t). Also, the symbol name
at point can be useful input even when it is not a file name or URL.

Sometimes, you might want the word at point (no symbol syntax) instead. So,
I use a user option that is a list of text-grabber functions - by default,
the first function grabs the symbol name at point, the second grabs the word
at point, and the third grabs the URL at point, prefixing it with http:// if
needed. In the minibuffer, a single `M-.' yanks the symbol name at point, a
second `M-.' replaces that with the word at point, and a third yanks the
URL. Other functions could be added to the list to do things like add
mailto: - the list is customizable.  In practice, I use a single `M-.' 90%
of the time, a second `M-.' 10% of the time, and a third `M-.' 0% of the
time (so far). A symbol name is usually the text I want to yank.

The other thing to mention is that many commands offer a default value that
is the word or symbol name at point. But other commands instead offer a
different default value that is deemed better most of the time. Providing
`M-.' lets you get the text at point even when the command's default value
is something else. You can think of it as an extension to `M-n' in this
respect.

Any interest in adding such a feature?  Who will be the first to let me know
that it already exists in some (better) form ;-)?






reply via email to

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