all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Karl Fogel <kfogel@red-bean.com>
To: Lars Magne Ingebrigtsen <larsi@gnus.org>
Cc: Stefan Monnier <monnier@IRO.UMontreal.CA>, emacs-devel@gnu.org
Subject: Re: "Staying in the same place"
Date: Mon, 04 Apr 2016 14:25:20 -0500	[thread overview]
Message-ID: <87h9fhrxb3.fsf@red-bean.com> (raw)
In-Reply-To: <m37fgdnrks.fsf@gnus.org> (Lars Magne Ingebrigtsen's message of "Mon, 04 Apr 2016 20:42:43 +0200")

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>
>> The important part is that you can build a "bookmark object" which should
>> contain enough data to reproduce the current buffer&position.
>
>Yes, but would that work they way I sketched out in the second message
>in this thread?  I.e., the mode would supply a function that would
>provide a list of (say) 20 places to look for a place that's "the same"?

Yes, see below...

>> You might be able to do that, but what I was proposing was not to let
>> users use the bookmark functionality, but simply to have a default
>> special-mode-revert-buffer function which would do something along
>> the lines of:
>>
>>     (defun special-mode-revert-function ()
>>       (let ((here (funcall bookmark-make-record-function)))
>>         (erase-buffer)
>>         (bookmark-goback here)))
>
>Aha, I see.  Yes, that sounds very nice.  As long as the bookmark
>functionality is sufficiently flexible about the `here' it's willing to
>accept..

So, stepping back a moment:

First, bookmark has the idea of a fuzzily-recorded place -- a position (in a buffer of text) that is somehow "the same" as it used to be, even though some things about the text have changed.  Obviously, if the text changes too much, the concept of "the same place" becomes meaningless, and bookmark can't recover the position.

Second, bookmark already has a mechanism for delegating that notion of a fuzzily-recorded position to other modes (e.g., to Info mode).

And Stefan has pointed out that what you're proposing is essentially what bookmark already does.  Maybe that idea of recording a position fuzzily should be abstracted out, and then bookmark would use the new abstraction too, or maybe this new function should just use bookmark's existing code (which, in turn, already hooks into mode-specific code in some cases, and could do more of that).

In any case, though, should the new thing be defined as a macro?  That seems like the more natural way, at least IMHO.  Something like:

(defmacro fuzzy-save-excursion (&rest body)
   record-the-position-fuzzily-using-mode-specific-code
   run-the-body
   restore-the-fuzzily-recorded-position
)

Or maybe:

(defmacro fuzzy-save-excursion (save-func restore-func &rest body)
   record-the-position-fuzzily-with-save-func
   run-the-body
   restore-using-restored-func
)

?

Best regards,
-Karl



  reply	other threads:[~2016-04-04 19:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-04  5:40 "Staying in the same place" Lars Magne Ingebrigtsen
2016-04-04  6:09 ` Lars Magne Ingebrigtsen
2016-04-04  7:28   ` Daniel McClanahan
2016-04-04 12:51 ` Stefan Monnier
2016-04-04 18:19   ` Lars Magne Ingebrigtsen
2016-04-04 18:36     ` Stefan Monnier
2016-04-04 18:42       ` Lars Magne Ingebrigtsen
2016-04-04 19:25         ` Karl Fogel [this message]
2016-04-04 19:43           ` Lars Magne Ingebrigtsen
2016-04-04 19:49             ` Karl Fogel
2016-04-04 19:52               ` Lars Magne Ingebrigtsen
2016-04-04 23:21                 ` John Wiegley
2016-04-05  0:36                   ` 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=87h9fhrxb3.fsf@red-bean.com \
    --to=kfogel@red-bean.com \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@IRO.UMontreal.CA \
    /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.