emacs-devel
[Top][All Lists]
Advanced

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

Re: Patch: enhanced mark navigation commands


From: Juri Linkov
Subject: Re: Patch: enhanced mark navigation commands
Date: Thu, 06 Mar 2008 02:54:54 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-unknown-linux-gnu)

> The attached lisp allows moving around within a buffer or buffers to
> places where recent edits or other events took place.  It has been
> part of Emacs.app for a while and users have found it useful; I'd like
> to propose it being added to the emacs distribution itself, probably
> as part of simple.el.
>
> Specifically, the keys M-p and M-n are bound to move forwards and
> backwards through the mark history.  Also, immediately after popping a
> global mark, e.g., with C-x C-SPC, then the global mark ring is used.

I used to have a similar feature in .emacs which I'd like to
demonstrate here just for reference:

(defun my-sorted-marks ()
  "Returns marks of the current buffer sorted by position."
  (sort (copy-list mark-ring)
        (lambda (m1 m2) (< (marker-position m1) (marker-position m2)))))

(defun my-mark-prev ()
  "Jump to the previous mark."
  (interactive)
  (let ((marks (reverse (my-sorted-marks))) m)
    (while (car marks)
      (if (< (marker-position (car marks)) (point))
          (setq m (car marks) marks nil)
        (setq marks (cdr marks))))
    (if m (goto-char m))))
(define-key global-map [(meta up)] 'my-mark-prev)

(defun my-mark-next ()
  "Jump to the next mark."
  (interactive)
  (let ((marks (my-sorted-marks)) m)
    (while (car marks)
      (if (> (marker-position (car marks)) (point))
          (setq m (car marks) marks nil)
        (setq marks (cdr marks))))
    (if m (goto-char m))))
(define-key global-map [(meta down)] 'my-mark-next)

It navigated marks spatially (by the order of buffer positions),
not temporally (by the order of adding marks to the mark ring).
But it turned out to be quite useless.

OTOH commands like you proposed would be more useful.  But they
are too intrusive.  I think it would be better to have two
commands `goto-prev-mark' and `goto-next-mark' that just move point
to the positions of marks in the mark ring without modifying it
(by using some global pointer for the current position in it).

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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