* Buffer Navigation @ 2005-10-19 2:18 Shug Boabby 2005-10-19 2:28 ` Drew Adams [not found] ` <mailman.11819.1129688923.20277.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 10+ messages in thread From: Shug Boabby @ 2005-10-19 2:18 UTC (permalink / raw) Hi everyone, The CVS GNU Emacs has introduced a neat way to navigate buffers with (C-x left/right), reproducible with the code at the end of this message for older Emacs versions. However, this navigation goes through *all* buffers, not just the ones I am editing/reading. Does anyone know of a way I could set up a similar navigation system that only navigates through *scratch* and files I have opened myself, i.e. not some temporary buffer a function or mode has created or opened. One possible solution I have thought of (*very* roundabout, I'm not proud of it) would be to create a wrapper function for opening/closing files which adds/removes the name of the file to/from a list (which is ordered in some way, such as alphabetically or chronological). then i bind C-x C-f and C-x k to these wrappers. then navigate only the buffers in that list. Please let me know if anyone has a better solution! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (if (< emacs-major-version 22) (progn (defalias 'switch-to-next-buffer 'bury-buffer) (defun switch-to-previous-buffer () "Switches to previous buffer" (interactive) (switch-to-buffer (nth (- (length (buffer-list)) 1) (buffer-list)))))) (if (< emacs-major-version 22) ; Use C-x <left> and C-x <right> (progn ; for buffer navigation (global-set-key [(control x) (left)] 'switch-to-previous-buffer) (global-set-key [(control x) (right)] 'switch-to-next-buffer))) ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Buffer Navigation 2005-10-19 2:18 Buffer Navigation Shug Boabby @ 2005-10-19 2:28 ` Drew Adams [not found] ` <mailman.11819.1129688923.20277.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 10+ messages in thread From: Drew Adams @ 2005-10-19 2:28 UTC (permalink / raw) The CVS GNU Emacs has introduced a neat way to navigate buffers with (C-x left/right)... Does anyone know of a way I could set up a similar navigation system that only navigates through *scratch* and files I have opened myself, i.e. not some temporary buffer a function or mode has created or opened. There are many libraries that let you quickly switch among existing buffers (ignoring the temporary buffers you want to ignore). Here is a good place to start: http://www.emacswiki.org/cgi-bin/wiki/SwitchingBuffers. I (naturally) recommend my own library, Icicles, which does what you want (IIUC) and more. The library is here: http://www.emacswiki.org/cgi-bin/emacs/icicles.el. Doc is here: http://www.emacswiki.org/cgi-bin/wiki/Icicles. HTH. ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <mailman.11819.1129688923.20277.help-gnu-emacs@gnu.org>]
* Re: Buffer Navigation [not found] ` <mailman.11819.1129688923.20277.help-gnu-emacs@gnu.org> @ 2005-10-19 2:38 ` Shug Boabby 2005-10-19 3:35 ` Drew Adams 2005-10-19 3:01 ` Shug Boabby 1 sibling, 1 reply; 10+ messages in thread From: Shug Boabby @ 2005-10-19 2:38 UTC (permalink / raw) thanks Drew... I skimmed the documentation which seems to focus on the completion power of icicle more than the buffer management. how would i use your library as a drop in replacement for my C-x left/right bindings? also, i'm not so keen on the C-h remapping... i unset that standard "helpful" binding as delete sends C-h in a compliant xterm. ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Buffer Navigation 2005-10-19 2:38 ` Shug Boabby @ 2005-10-19 3:35 ` Drew Adams 0 siblings, 0 replies; 10+ messages in thread From: Drew Adams @ 2005-10-19 3:35 UTC (permalink / raw) thanks Drew... I skimmed the documentation which seems to focus on the completion power of icicle more than the buffer management. That's because buffer management is but a tiny consequence of Icicles general behavior. Icicles does the same thing for any object (file, command, variable...) as it does for buffers. how would i use your library as a drop in replacement for my C-x left/right bindings? Better to continue off-list if you have more questions, as the details are probably not interesting to others. Anyway, this should get you started: Just use your standard buffer-switching command - for example, `switch-to-buffer' (on `C-x b'). Then use the up/down arrows (or `C-p'/`C-n') to cycle among buffer-names and choose one (RET). This doesn't let you use `C-x left' and `C-x right' - you use up/down instead (fewer keystrokes). Even better: use command `icicle-buffer'. Make these bindings, for example. (define-key ctl-x-map "b" 'icicle-buffer) ; `C-x b' (define-key ctl-x-4-map "b" 'icicle-buffer-other-window) ; `C-x 4 b' Now do as in #1, or you can use `C-up'/`C-down' to cycle among buffers, switching to them at the same time (no need to hit `RET'). With `C-x b' the switched-to buffer replaces the current buffer in its window. With `C-x 4 b' the switched-to buffer is opened in another window. also, i'm not so keen on the C-h remapping... i unset that standard "helpful" binding as delete sends C-h in a compliant xterm. `C-h' is only rebound for the minibuffer - Icicles changes no global bindings. From what you said, you've apparently already figured out how to unset the `C-h' bindings (and bind `icicle-help-on-candidate' to another minibuffer key sequence). ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Buffer Navigation [not found] ` <mailman.11819.1129688923.20277.help-gnu-emacs@gnu.org> 2005-10-19 2:38 ` Shug Boabby @ 2005-10-19 3:01 ` Shug Boabby 2005-10-19 3:35 ` Drew Adams 2005-10-19 22:54 ` Thien-Thi Nguyen 1 sibling, 2 replies; 10+ messages in thread From: Shug Boabby @ 2005-10-19 3:01 UTC (permalink / raw) from that wiki entry i found the bs calls... silly me for trying to re-implement their simple next/previous stuff. bs-show is nice too. however, none of these numerous adons do what i want... which is to only navigate through files which i, myself, not some mode or function call, have opened. i don't want to go writing out regexs for the types of files i usually edit... i just want emacs to be smart enough to know what i have opened by hand. is that kind of information stored anyway? or is writing a wrapper for open/close the only solution... ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: Buffer Navigation 2005-10-19 3:01 ` Shug Boabby @ 2005-10-19 3:35 ` Drew Adams 2005-10-19 22:54 ` Thien-Thi Nguyen 1 sibling, 0 replies; 10+ messages in thread From: Drew Adams @ 2005-10-19 3:35 UTC (permalink / raw) from that wiki entry i found the bs calls... silly me for trying to re-implement their simple next/previous stuff. bs-show is nice too. however, none of these numerous adons do what i want... which is to only navigate through files which i, myself, not some mode or function call, have opened. i don't want to go writing out regexs for the types of files i usually edit... i just want emacs to be smart enough to know what i have opened by hand. is that kind of information stored anyway? or is writing a wrapper for open/close the only solution... Buffer and file commands normally filter out uninteresting buffers (those whose names start with a space) and files (those whose names match `completion-ignored-extensions', for example), but that isn't exactly what you're asking for. You can certainly write something yourself - just keep track of the buffers and files you open yourself. If you put their names on a list, you can use Icicles cycling and completion to access them. But this requires a little Emacs Lisp. If a list of recently used files is sufficient for you (they might not still be open, so this is not exactly what you asked for), then there are libraries that do that too. Icicles, for instance, has commands `icicle-recent-file' and `icicle-recent-file-other-window', which let you open a recently visited file (filename completion and cycling available, as usual). This uses library `recentf.el', which persistently records your visited files. You can also cycle through the files you opened during the current session only, by using Icicles command `icicle-history' (bound to `M-h' in the minibuffer). You can use this on any minibuffer input, including filename input. During file-name completion, it lets you complete to, or cycle through, your recently visited files of the current session. For instance, `C-x f', then `M-h', then use up/down arrows to cycle through recent files and choose one (RET). (If you use library `savehistory.el', then `icicle-history' uses the persistent minibuffer histories saved by that library.) HTH. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Buffer Navigation 2005-10-19 3:01 ` Shug Boabby 2005-10-19 3:35 ` Drew Adams @ 2005-10-19 22:54 ` Thien-Thi Nguyen 2005-10-20 22:43 ` Shug Boabby 1 sibling, 1 reply; 10+ messages in thread From: Thien-Thi Nguyen @ 2005-10-19 22:54 UTC (permalink / raw) "Shug Boabby" <Shug.Boabby@gmail.com> writes: > is writing a wrapper for open/close the only solution... write a function that sets a buffer-local variable (for example, you could name it `shug-boabby-interesting-buffer-p') to a recognizable value. arrange for `find-file-hook' to call this function, but only if `this-command' is `find-file'. use your buffer-selection/management package of choice to test for this value during its filtering pass. when you kill the buffer, the buffer-local variable will be deleted along w/ the buffer, so that side of things is worry free. of course, you can write a wrapper anyway for the exercise. there's nothing wrong w/ finding and following many paths. thi ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Buffer Navigation 2005-10-19 22:54 ` Thien-Thi Nguyen @ 2005-10-20 22:43 ` Shug Boabby 2005-10-21 17:01 ` Kevin Rodgers [not found] ` <mailman.12151.1129914597.20277.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 10+ messages in thread From: Shug Boabby @ 2005-10-20 22:43 UTC (permalink / raw) actually the bs- commands seem to be doing what i want. with one small issue to sort out: i currently have: (setq bs-default-sort-name "by name") (setq bs-must-always-show-regexp "\\*scratch\\*\\|\\*Python\\*") (setq bs-dont-show-regexp "*_region_\\.tex*") but the buffer (and file) named "_region_.tex" keeps appearing in my buffer list! grr... how do i get it out of my buffer menu and cycle list? i can't seem to get the dont-show list working for anything... am i setting it's value correctly? is it perhaps broken in the CVS Emacs at the moment? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Buffer Navigation 2005-10-20 22:43 ` Shug Boabby @ 2005-10-21 17:01 ` Kevin Rodgers [not found] ` <mailman.12151.1129914597.20277.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 10+ messages in thread From: Kevin Rodgers @ 2005-10-21 17:01 UTC (permalink / raw) Shug Boabby wrote: > actually the bs- commands seem to be doing what i want. with one small > issue to sort out: i currently have: > > (setq bs-default-sort-name "by name") > (setq bs-must-always-show-regexp "\\*scratch\\*\\|\\*Python\\*") > (setq bs-dont-show-regexp "*_region_\\.tex*") > > but the buffer (and file) named "_region_.tex" keeps appearing in my > buffer list! grr... how do i get it out of my buffer menu and cycle > list? i can't seem to get the dont-show list working for anything... am > i setting it's value correctly? is it perhaps broken in the CVS Emacs > at the moment? The asterisk at the beginning of the regexp is interpreted literally. I think you want just (setq bs-dont-show-regexp "_region_\\.tex") -- Kevin Rodgers ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <mailman.12151.1129914597.20277.help-gnu-emacs@gnu.org>]
* Re: Buffer Navigation [not found] ` <mailman.12151.1129914597.20277.help-gnu-emacs@gnu.org> @ 2005-10-23 19:54 ` Shug Boabby 0 siblings, 0 replies; 10+ messages in thread From: Shug Boabby @ 2005-10-23 19:54 UTC (permalink / raw) cheers kevin, but apparently in newer versions of emacs (and i suppose incorrectly documented for older versions of bs-*), this is not a user editable variable... talk about killing the power of the mode. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2005-10-23 19:54 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-10-19 2:18 Buffer Navigation Shug Boabby 2005-10-19 2:28 ` Drew Adams [not found] ` <mailman.11819.1129688923.20277.help-gnu-emacs@gnu.org> 2005-10-19 2:38 ` Shug Boabby 2005-10-19 3:35 ` Drew Adams 2005-10-19 3:01 ` Shug Boabby 2005-10-19 3:35 ` Drew Adams 2005-10-19 22:54 ` Thien-Thi Nguyen 2005-10-20 22:43 ` Shug Boabby 2005-10-21 17:01 ` Kevin Rodgers [not found] ` <mailman.12151.1129914597.20277.help-gnu-emacs@gnu.org> 2005-10-23 19:54 ` Shug Boabby
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).