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

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

RE: bookmark position at end of file


From: Drew Adams
Subject: RE: bookmark position at end of file
Date: Sat, 27 Feb 2010 08:36:26 -0800

> bookmark-set stores the position in the as well as some surrounding
> context. This is perfect if one wants to return to exactly that
> position. But is it also possible to set bookmark position to 
> point-max independent of what the context is?
> 
> Use case: When I visit a bookmarked log file where data is appended
> constantly I would like to end up at the end of the file to 
> see the most recent entry.

1. The easiest way is just to use `bookmark-after-jump-hook'. Add a function to
this hook that goes to the end of the buffer if the buffer is a log. Example:

(add-hook 'bookmark-after-jump-hook 'foo)
(defun foo ()
  (when (string= "log" (file-name-extension (buffer-file-name)))
    (end-of-buffer)))


2. Alternatively, you can define your own bookmark type, in this case a log-file
type, by defining a handler for log files. There are two pieces:

2a. Add `(handler . log-bookmark-jump)' to bookmarks in log files. You do this
by setting variable `bookmark-make-record-function' in your mode (log mode,
which you'll presumably define) to a function that creates the bookmark the way
you want it.

(set (make-local-variable 'bookmark-make-record-function)
       'log-mode-bookmark-make-record)

2b. Define `log-bookmark-jump' to do what you want.

See `Info-bookmark-make-record' and `Info-bookmark-jump' for examples.







reply via email to

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