unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: "Adrian Robert" <adrian.b.robert@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Patch: enhanced mark navigation commands
Date: Thu, 06 Mar 2008 02:54:54 +0200	[thread overview]
Message-ID: <874pbkmzbx.fsf@jurta.org> (raw)
In-Reply-To: <55f7df060803042112w380b5170qe964002c6c06ab01@mail.gmail.com> (Adrian Robert's message of "Wed, 5 Mar 2008 08:12:35 +0300")

> 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/




      parent reply	other threads:[~2008-03-06  0:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-05  5:12 Patch: enhanced mark navigation commands Adrian Robert
2008-03-05  6:19 ` Miles Bader
2008-03-05 12:23   ` paul r
2008-03-05  6:41 ` Dan Nicolaescu
2008-03-06  0:57   ` Juri Linkov
2008-03-06  1:47     ` Dan Nicolaescu
2008-03-06  7:18       ` Drew Adams
2008-03-06 10:09       ` Juri Linkov
2008-03-09 21:55     ` Juri Linkov
2008-03-05 16:11 ` Ted Zlatanov
2008-03-05 19:20   ` Stefan Monnier
2008-03-05 19:48     ` Ted Zlatanov
2008-03-05 22:10       ` Miles Bader
2008-03-10 13:09         ` Ted Zlatanov
2008-03-10 22:34           ` Juri Linkov
2008-03-11 15:08             ` Ted Zlatanov
2008-03-06  0:54 ` Juri Linkov [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=874pbkmzbx.fsf@jurta.org \
    --to=juri@jurta.org \
    --cc=adrian.b.robert@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

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

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