[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Patch: enhanced mark navigation commands
From: |
Drew Adams |
Subject: |
RE: Patch: enhanced mark navigation commands |
Date: |
Wed, 5 Mar 2008 23:18:49 -0800 |
FWIW, in Icicles you can navigate among the markers in a buffer or among
global markers, in any order.
While doing that, you can complete against the text on each marker's line
(or "<EMPTY LINE>"): each completion candidate is an alist entry (line-text
. marker). More typically, however, you cycle among the markers or click
them in *Completions* with the mouse. You can cycle in either direction, and
you need not visit each marker in sequence (direct access or skip some).
You can sort the candidate marker list in various ways - by default, the
candidates are in marker order (i.e. buffer position). If unsorted, they are
in chronological order, i.e., mark-ring insertion order. Hit a key to change
the sort order - you can have any number of orders.
You can filter the set of candidate markers by matching (or
complement-matching) your minibuffer input against each marker's line. When
you visit a marker, its line is highlighted temporarily. It is a bit like a
dynamic `occur' command (change your input on the fly and it changes the
matching candidates), but an `occur' where the lines are only those with
markers and each marker has a line (candidate).
This all falls out for free by using the general function (command)
`icicle-map' to define the navigating commands (`icicle-goto-marker' and
`icicle-goto-global-marker'). Those definitions are trivial. `icicle-map'
applies a function to alist-entry completion candidates that are chosen
interactively, e.g. by cycling.
In the case of the marker-navigator commands, the function applied by
`icicle-map' just goes to the chosen marker candidate and highlights its
line:
(defun goto-and-highlight (cand)
(pop-to-buffer (marker-buffer (cdr cand)))
(goto-char (cdr cand))
(setq mark-active nil)
(let ((hl-line-flash-show-period 60)) (hl-line-flash)))
(point-marker))))) ; Return marker at point, for message.
The complete definition of `icicle-go-to-marker is this (plus some bindings
for sort functions and an error message if no markers):
(defun icicle-goto-marker ()
"Go to a marker in this buffer."
(interactive)
(icicle-map (mapcar #'icicle-marker+text
(icicle-markers mark-ring))
#'goto-and-highlight)))
Function `icicle-marker+text' just creates an alist entry (completion
candidate) using the text of a marker's line as car and the marker as cdr.
Function `icicle-markers' just filters the `mark-ring' for live buffers,
excluding the minibuffer.
You can use `icicle-map' to define a command to traverse any alist, doing
anything you want to the entries. The user picks the entries to act on, in
the ways mentioned above (filter, sort, cycle, complete, choose directly).
The user can act on candidates repeatedly and in any order.
`icicle-map' and commands such as `icicle-goto-marker' that you define using
it are multi-commands. It is that that lets a user choose multiple
completion candidates (e.g. cycle among them) in a single command
invocation.
- Patch: enhanced mark navigation commands, Adrian Robert, 2008/03/05
- Re: Patch: enhanced mark navigation commands, Ted Zlatanov, 2008/03/05
- Re: Patch: enhanced mark navigation commands, Stefan Monnier, 2008/03/05
- Re: Patch: enhanced mark navigation commands, Ted Zlatanov, 2008/03/05
- Re: Patch: enhanced mark navigation commands, Miles Bader, 2008/03/05
- Re: Patch: enhanced mark navigation commands, Ted Zlatanov, 2008/03/10
- Re: Patch: enhanced mark navigation commands, Juri Linkov, 2008/03/10
- Re: Patch: enhanced mark navigation commands, Ted Zlatanov, 2008/03/11
Re: Patch: enhanced mark navigation commands, Juri Linkov, 2008/03/05