[Top][All Lists]

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

RE: Emacs navigation mode

From: Drew Adams
Subject: RE: Emacs navigation mode
Date: Mon, 2 Apr 2012 16:59:18 -0700

> automatically remembers positions in buffers you were
> watching long enough and lets you easily jump between them 
> (in linear style, not Emacs-undo-style).

I guess you mean that if Emacs is idle for a given amount of time then the
position of the cursor (or perhaps its current line) is automatically remembered
on a list, and you can navigate to positions on the list.

1. Without the automatic remembering part there are a number of possibilities,
including bookmarking and setting markers.  IOW, some explicit user action sets
a bookmark or sets a marker.

See the Emacs Wiki for different possibilities:

2. For the automatic-remembering part, you can put the bookmark-setting action
on an idle timer.  IOW, have Emacs automatically set a bookmark or a marker
whenever Emacs is idle for a given delay.

For bookmarks, if you use Bookmark+ then you can use persistent or temporary
bookmarks, including with automatic naming if you like (with the position in the
name).  You can have them show up visually (be highlighted) or not.  You can
cycle among any set of bookmarks.  See below for an example.

With Bookmark+ you can easily navigate among bookmarks: cycling, direct access,
access using completion.  With Icicles you can do the same with Emacs markers
(local or global).  With both libraries, navigating among bookmarks is even
easier. (navigate/cycle among
markers) (bookmark navigation
lists & cycling)

A quick example thrown together to show one way of doing automatic idle
bookmarking with Bookmark+ (

1. (Optional) To make autonamed bookmarks always be temporary (not saved),
customize option `bmkp-autotemp-bookmark-predicates' to include
`bmkp-autonamed-bookmark-p'.  To test, you can just do this:

(setq bmkp-autotemp-bookmark-predicates  '(bmkp-autonamed-bookmark-p))

2. (Optional) To highlight autonamed bookmarks when they are set, customize
option `bmkp-auto-light-when-set' to `autonamed-bookmark'.  To test, you can
just do this:

(setq bmkp-auto-light-when-set 'autonamed-bookmark)

3. Define the number of idle seconds before setting a bookmark:

(defcustom auto-idle-bookmark-mode-delay 30
  "Secs before automatically setting a bookmark."
  :type 'integer :group 'bookmark-plus)

4. Define an idle timer:

(defvar auto-idle-bookmark-mode-timer
  (progn (when (timerp 'auto-idle-bookmark-mode-timer)
           (cancel-timer auto-idle-bookmark-mode-timer))
         (prog1 (run-with-idle-timer
                 auto-idle-bookmark-mode-delay t
           (when (timerp 'auto-idle-bookmark-mode-timer)
             (cancel-timer auto-idle-bookmark-mode-timer))))
  "Timer for `auto-idle-bookmark-mode'.")

5. Define a command to turn automatic bookmarking on/off:

(define-minor-mode auto-idle-bookmark-mode
    "Toggle automatic setting of a bookmark when Emacs is idle"
  :init-value nil :global t :lighter " BMK"
  (cancel-timer auto-idle-bookmark-mode-timer)
  (when auto-idle-bookmark-mode
    (setq auto-idle-bookmark-mode-timer
           auto-idle-bookmark-mode-delay t

6. Turn it on: `M-x auto-idle-bookmark-mode'.

7. To cycle among the bookmarks in the current buffer, use `C-x p down' (`down'
`down'...), or `up'.  If you have Icicles, you can navigate more flexibly,
combining direct access with cycling and completion.

8. The function used in #5 to set a bookmark is
`bmkp-set-autonamed-bookmark-at-line'.  It sets it at the beginning of the
current line.  If you instead want to bookmark at point, so you can have more
than one such bookmark on the same line, then use `bmkp-set-autonamed-bookmark'
(no `-at-line').

9. Because of #1, all of the bookmarks created this way are temporary: not saved
to your bookmarks file.  You can also delete them all at anytime using `M-x
bmkp-delete-all-temporary-bookmarks'.  You can also delete any of them
individually by putting the cursor on its line (or its position, if you don't
use (`-at-line') and hitting `C-x p RET' - this key creates/deletes an autonamed
bookmark at point.

10. If you do not want to highlight the bookmarks, don't do #2.  If you want to
unhighlight them at any time, use `C-x p u' (all in the buffer) or `C-x p C-u'
(the bookmark on the same line as cursor).  See also `C-x p U'.


reply via email to

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