all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: brakjoller@hotmail.com (Barman Brakjoller)
Subject: Re: how to just back to previous location quickly?
Date: 25 Apr 2003 01:27:48 -0700	[thread overview]
Message-ID: <1c58a7c3.0304250027.f0b7daa@posting.google.com> (raw)
In-Reply-To: 62ede926.0304240450.47d6df07@posting.google.com

> I've been using the following code for several years and I am very
> happy with it. You just quickly store your position (using C-. in my
> setting), move somewhere else and then can toggle between the stored
> and the new position using C-,.
> 
> Of course the keybinding is a matter of taste...

And here is mine, which is very similar. The big difference is that
once you jumped back to the saved position, you can jump between the
two by using jump-last-posiiton:

(defun save-current-position ()
  "Saves current cursor position in register 0"
  (interactive)
  (point-to-register 0)
  (delete (assoc 1 register-alist) register-alist)
  (message "Position saved."))

(defun jump-last-position ()
  "Jump to position saved with previous `save-current-position´,
OR if run two times with no `save-current-position´ in between,
jump to the last position it was run from."
  (interactive)
  (if (get-register 0)
      (progn
        (point-to-register 1)
        (jump-to-register 0)
        (delete (assoc 0 register-alist) register-alist)
        (message "Jumped to last saved or last jump-position"))
    (if (get-register 1)
        (progn
          (point-to-register 0)
          (jump-to-register 1)
          (delete (assoc 1 register-alist) register-alist)
          (message "Jumped to last saved or last jump-position"))
      (message "No pos saved"))))

Of course it is quite ugly to just hijack register 0, but it is a
register that a user at least cannot type using the keyboard (or maybe
by using C-q first, I don't know and I don't care... :)

      parent reply	other threads:[~2003-04-25  8:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-24  8:52 how to just back to previous location quickly? wang yin
2003-04-24 12:50 ` Stefan Kamphausen
2003-04-24 14:27   ` wang yin
2003-04-26 15:31     ` Oliver Scholz
2003-04-25  8:27   ` Barman Brakjoller [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

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

  git send-email \
    --in-reply-to=1c58a7c3.0304250027.f0b7daa@posting.google.com \
    --to=brakjoller@hotmail.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.