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

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

RE: Looking for a buffer-cycling library


From: Drew Adams
Subject: RE: Looking for a buffer-cycling library
Date: Sat, 15 Nov 2014 09:17:00 -0800 (PST)

> >> I'm looking for a buffer cycling mechanism that will ignore
> >> any buffer not loaded from or written to a file.  Example -
> >> any buffer whose name begins with '*' would be "jumped over"
> 
> Just my 2 cents: why not use Icicles?

Icicles does let you "ignore any buffer not loaded from or
written to a file".

To do that, just use a positive prefix arg with `icicle-buffer':
`M-1 C-x b'.  That limits the candidates to names of buffers
visiting files & directories.

(Or define your own command that binds `current-prefix-arg' to
a positive integer and invokes `icicle-buffer'.)

You can also exclude or include particular buffer names using
these user options (customize them or bind them in your own
commands):

 `icicle-buffer-match-regexp'    - Regexp buffer names must match
 `icicle-buffer-no-match-regexp' - Regexp names must not match
 `icicle-buffer-predicate'       - Predicate names must satisfy
 `icicle-buffer-extras'          - Extra buffer names to display

For example, to change the default behavior to show only buffers
associated with files (so no need to use a prefix arg, and exclude
also directories), set `icicle-buffer-predicate' to this:
(lambda (bf) (buffer-file-name bf))

However, the OP also wants to use terminal mode.  Icicles can be
used in terminal mode, but it no doubt calls for customizing some
minibuffer key bindings, as some of the default bindings are for
keys that terminals do not support.  (I don't use terminal mode
anymore, and I don't make much effort to support it for Icicles,
but I do know that some people use Icicles with terminal mode.)

---

Here is the (long) doc for command `icicle-buffer' (`C-x b' in
Icicle mode, by default):

,----
| icicle-buffer is an interactive Lisp function in `icicles-cmd1.el'.
| 
| It is bound to menu-bar buffer Icicles icicle-buffer, C-x b, menu-bar
| buffer select-named-buffer.
| 
| (icicle-buffer)
| 
| Switch to a different buffer, whose content contains a regexp match.
| By default, Icicle mode remaps all key sequences that are normally
| bound to `switch-to-buffer' to `icicle-buffer'.  If you do not want
| this remapping, then customize option `icicle-top-level-key-bindings'.
| 
| Completion candidates are two-part multi-completions, with the second
| part optional.  If both parts are present they are separated by
| `icicle-list-join-string' ("^G^J", by default).
| 
| The first part is matched as a regexp against a buffer name.
| The second part is matched as a regexp against buffer content.
| Candidates that do not match are filtered out.
| 
| When matching buffer content, Icicles just looks for a single match.
| Visiting the buffer does not move to that match or to any other match.
| Matching is used only to filter candidate buffers.
| 
| However, if your input includes a content-matching part and it
| matches, that part is automatically added to the Isearch regexp
| history, `regexp-search-ring' whenever you hit `S-TAB' to complete.
| This means that when you visit the buffer you can immediately search
| for matches using `C-M-s' or `C-M-r'.
| 
| Your minibuffer input can match a buffer name or buffer content, or
| both.  Use `C-M-j' (equivalent here to `C-q C-g C-j') to input the
| default separator.
| 
| For example:
| 
| To match `foo' against buffer names, use input `foo'.
| To match `bar' against buffer contents, use input `C-M-j bar'.
| To match both, use input `foo C-M-j bar'.
| 
| Only the matching buffer names are shown in `*Completions*', and only
| the chosen buffer name is returned.  The actual content matches are
| unimportant anyway: content matching is used only to filter
| candidates.
| 
| This is a buffer-switching command.  If you instead want to navigate
| to text searched for in buffers then use `icicle-search'.
| 
| The buffer-name portion of completion candidates is as follows,
| depending on the prefix arg:
| 
| * No prefix arg: all buffers
| * Numeric arg > 0: buffers visiting files or directories (Dired)
| * Numeric arg < 0: buffers associated with the selected frame
| * Numeric arg = 0: buffers with the same mode as the current buffer
| * Plain prefix arg (`C-u'): buffers with the same mode as current,
|   or with a mode that the current mode is derived from
| * Double plain (`C-u C-u'): visible buffers (possibly iconified)
| * Triple plain (`C-u C-u C-u'): invisible buffers
| 
| Those are the default prefix-argument behaviors, but you can change
| them using option `icicle-buffer-prefix-arg-filtering'.
| 
| For Emacs 23 and later, the default values (via `M-n') are the
| (buffer-name components of the) first four completion candidates
| (respecting the prefix argument).
| 
| You can use these additional keys during completion:
| 
| * `C-x F'     Toggle including cached file names as candidates (option
|               `icicle-buffer-include-cached-files-nflag').
| * `C-x R'     Toggle including recent file names as candidates (option
|               `icicle-buffer-include-recent-files-nflag').
| * `C-x m'     Visit a bookmarked buffer (only if you use Bookmark+).
| * `C-x M -'   Remove buffers in a given mode.  Repeatable.
| * `C-x M +'   Keep only buffers in a given mode.
| * `C-x C-m -' Remove candidate buffers whose mode is derived from a
|               given mode.  Repeatable.  (`C-m' = `RET'.)
| * `C-x C-m +' Keep only buffers in a mode derived from a given mode.
| * `C-x v -'   Remove buffers that are visible (maybe iconified).
| * `C-x v +'   Keep only buffers that are visible (maybe iconified).
| * `<S-delete>'  Kill the buffer named by a completion candidate.
| 
| Those are default key bindings, but you can change them using option
| `icicle-buffer-candidate-key-bindings'.
| 
| These options, when non-nil, control candidate matching and filtering:
| 
|  `icicle-buffer-extras'             - Extra buffer names to display
|  `icicle-buffer-ignore-space-prefix-flag' - Ignore space-prefix names
|  `icicle-buffer-include-cached-files-nflag' - Include cached files
|  `icicle-buffer-include-recent-files-nflag' - Include recent files
|  `icicle-buffer-match-regexp'       - Regexp buffer names must match
|  `icicle-buffer-no-match-regexp'    - Regexp names must not match
|  `icicle-buffer-predicate'          - Predicate names must satisfy
|  `icicle-buffer-sort'               - Sort function for candidates
|  `icicle-buffer-skip-functions'     - Exclude from content searching
|  `icicle-file-skip-functions'       - Same, but cached/recent files
| 
| For example, to change the default behavior to show only buffers that
| are associated with files, set `icicle-buffer-predicate' to this:
| 
|  (lambda (bufname) (buffer-file-name (get-buffer bufname)))
| 
| Option `icicle-buffer-require-match-flag' can be used to override
| option `icicle-require-match-flag'.
| 
| Option `icicle-buffers-ido-like' non-nil gives this command a more
| Ido-like behavior.
| 
| See also command `icicle-buffer-no-search', which is `icicle-buffer'
| without the multi-completion behavior that searches buffer content.
| 
| See also command `icicle-buffer-config', which lets you choose a
| configuration of user options for commands such as `icicle-buffer'.
| 
| Note: The prefix arg is tested, even when this is called
| noninteractively.  Lisp code can bind `current-prefix-arg' to control
| the behavior.
| 
| Read input, then act on it.
| 
| Input-candidate completion and cycling are available.  While cycling,
| these keys with prefix `C-' are active:
| 
| `C-mouse-2', `C-return' - Act on current completion candidate only
| `C-down', `C-wheel-down' - Move to next completion candidate and act
| `C-up', `C-wheel-up' - Move to previous completion candidate and act
| `C-next'  - Move to next apropos-completion candidate and act
| `C-prior' - Move to previous apropos-completion candidate and act
| `C-end'   - Move to next prefix-completion candidate and act
| `C-home'  - Move to previous prefix-completion candidate and act
| `C-!'     - Act on *all* candidates, successively (careful!)
| 
| When candidate action and cycling are combined (e.g. `C-next'), user
| option `icicle-act-before-cycle-flag' determines which occurs first.
| 
| With prefix `C-M-' instead of `C-', the same keys (`C-M-mouse-2',
| `C-M-RET', `C-M-down', and so on) provide help about candidates.
| 
| Use `mouse-2', `RET', or `S-RET' to finally choose a candidate, or
| `C-g' to quit.
| 
| This is an Icicles command - see command `icicle-mode'.
`----



reply via email to

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