[Top][All Lists]

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

Re: "Staying in the same place"

From: Karl Fogel
Subject: Re: "Staying in the same place"
Date: Mon, 04 Apr 2016 14:25:20 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux)

Lars Magne Ingebrigtsen <address@hidden> writes:
>Stefan Monnier <address@hidden> 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

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 

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)

Or maybe:

(defmacro fuzzy-save-excursion (save-func restore-func &rest body)


Best regards,

reply via email to

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