emacs-devel
[Top][All Lists]
Advanced

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

RE: [PATCH] Make eshell ‘ls’ output clickable.


From: Drew Adams
Subject: RE: [PATCH] Make eshell ‘ls’ output clickable.
Date: Fri, 7 Jul 2017 11:25:37 -0700 (PDT)

> > I feel this indicates a wider need, not specific to eshell, to dig out
> > "things" from text and act on them, guessing their proper handler.
> > Maybe it already exists?
> 
> ‘find-file-at-point’ comes to mind. Maybe it could be extended, or
> made one of backends, to ‘dwim-at-point’.

1. The general way to handle grabbing something at point is
to use `thingatpt.el'.  For file names and URLS, however,
`ffap.el' (specifically `ffap-guesser') works better, IMO.

The thing-at-point approach requires only that you define,
for any given type of <THING>, a `forward-<THING>' function
or both a `beginning-<THING>' and `end-<THING>' function.

Emacs comes with several such functions predefined, e.g.,
`forward-sexp'.


2. Your suggestion of `dwim-at-point' would mean doing the
right thing either (1) in general (a compromise, picked
to fit many common contexts) or (2) in a context-dependent
way.


3. FWIW, I've suggested before that Emacs do what Icicles
does: Let you use a key from the minibuffer (Icicles uses
`M-.') to grab something from some text at or near point
and append it to the minibuffer input.

(This is available whether or not completion is available
for the minibuffer input - it has nothing to do with
completion.)

Icicles `M-.' (`icicle-insert-string-at-point') is a
bit fancy (but Emacs need not do likewise):

For repetitions of `M-.', you have a choice: either
(1) successive things of the same type are inserted
from the buffer (more of the same) or (2) a different
type of thing from the buffer replaces the thing just
inserted (alternative things).

You choose via option `icicle-default-thing-insertion'.
(When you use `M-.', a plain prefix arg (`C-u') flips
the behavior of the option.)

Option `icicle-thing-at-point-functions' is where you
specify (a) the function used for #1, above, i.e.,
what type of thing to grab and (b) a list of alternative
thing-grabbing functions, for #2, above.

The behavior of a _numeric_ prefix arg N with `M-.'
depends on the default-insertion behavior you choose.
If it is #1, above, then N things of the given type are
inserted.  If it is #2, above, then the text at point is
grabbed as a Lisp sexp, evaluated, and the return value
is inserted.

[If you also use library `thingatpt+.el' then #2 with
a numeric prefix arg is handy if you are editing Lisp
code, since by default the grabbing alternatives
include 3 functions that retrieve different levels of
list near point.]

https://www.emacswiki.org/emacs/Icicles_-_Inserting_Text_from_Cursor



reply via email to

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