all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Earendil'" <matcio1@gmail.com>, <Help-gnu-emacs@gnu.org>
Subject: RE: Emacs navigation mode
Date: Mon, 2 Apr 2012 16:59:18 -0700	[thread overview]
Message-ID: <53257D223EF948C2A8C83ADBDB4CE62D@us.oracle.com> (raw)
In-Reply-To: <33545005.post@talk.nabble.com>

> 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: 
http://emacswiki.org/emacs/BookMarks
http://emacswiki.org/emacs/MarkCommand


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.

http://emacswiki.org/emacs/MarkCommands#IciclesGoToMarker (navigate/cycle among
markers)

http://www.emacswiki.org/cgi-bin/wiki/BookmarkPlus#toc47 (bookmark navigation
lists & cycling)


A quick example thrown together to show one way of doing automatic idle
bookmarking with Bookmark+ (http://emacswiki.org/emacs/BookmarkPlus):

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
                 #'bmkp-set-autonamed-bookmark-at-line)
           (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
          (run-with-idle-timer
           auto-idle-bookmark-mode-delay t
           #'bmkp-set-autonamed-bookmark-at-line))))

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'.

HTH.




  parent reply	other threads:[~2012-04-02 23:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-02 19:01 Emacs navigation mode Earendil
2012-04-02 19:20 ` Thien-Thi Nguyen
2012-04-02 19:25   ` Deniz Dogan
2012-04-02 19:26     ` Deniz Dogan
     [not found]     ` <mailman.383.1333394813.20052.help-gnu-emacs@gnu.org>
2012-04-02 21:27       ` Rud1ger Sch1erz
2012-04-02 23:03         ` Madan Ramakrishnan
     [not found]   ` <mailman.382.1333394753.20052.help-gnu-emacs@gnu.org>
2012-04-02 20:04     ` Barry Margolin
2012-04-02 23:59 ` Drew Adams [this message]
2012-04-04 13:32   ` M B
2012-04-05 15:12     ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53257D223EF948C2A8C83ADBDB4CE62D@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=Help-gnu-emacs@gnu.org \
    --cc=matcio1@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.