unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Magne Ingebrigtsen <larsi@gnus.org>
To: emacs-devel@gnu.org
Subject: Re: "Staying in the same place"
Date: Mon, 04 Apr 2016 08:09:31 +0200	[thread overview]
Message-ID: <m3inzx6h2c.fsf@gnus.org> (raw)
In-Reply-To: <m3oa9q53uq.fsf@gnus.org> (Lars Magne Ingebrigtsen's message of "Mon, 04 Apr 2016 07:40:13 +0200")

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> I wonder if anybody has thought about the issue in a more general way --
> by providing a mechanism to save (perhaps a lot) of context, and then
> trying to go back to the same context again after regenerating the
> buffer, in a ... fuzzy way.

Thinking about this a bit more, I think it's difficult to see a way to
do this generally without support from each mode.  However:

In general, if the buffer reflects things that don't really change a
lot, just recording the current line (and the next and previous ten
lines, say), would DWIM.

For buffers where there is a strong "identity" (say, file names in dired
and bug numbers in debbugs mode), the mode could provide a way to give
those identities to `revert-buffer' (and a way to restore point).

Take compilation modes, for instance.  Let's say there's a variable
`revert-buffer-context-function'.  The mode would return a list of error
points...

make -k 
  CC       vm-limit.o
  CC       dispnew.o
  CC       frame.o
frame.c: In function 'x_set_frame_parameters':
frame.c:3296:25: warning: 'height' may be used uninitialized in this function [-Wmaybe-uninitialized]
frame.c:3296:25: warning: 'width' may be used uninitialized in this function [-Wmaybe-uninitialized]
  CC       scroll.o
  CC       xdisp.o
xdisp.c: In function 'move_it_in_display_line_to':
xdisp.c:8556:13: warning: 'closest_pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
xdisp.c: In function 'display_line':
xdisp.c:20348:8: warning: 'max_bpos' may be used uninitialized in this function [-Wmaybe-uninitialized]
 ...

The list would perhaps be '("^frame.c:3296:" "^xdisp.c:8556:" ...).
`revert-buffer' would then basically do

(let ((context (funcall revert-buffer-context-function)))
  (funcall revert-buffer-function)
  (revert-buffer-restore-point context))

which would use those regexps to put point somewhere DWIM-ey.  And there
could be a `revert-buffer-restore-point-function' variable, too, if the
mode needs a more specialised way to use the context.

Of course, the this specific example, this wouldn't work, since
compilation is asynchronous, but the compilation mode could just use the
context itself from the filter.  Or the sentinel.  Or something.

Hm...

But I think this approach might work for many modes...  perhaps...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



  reply	other threads:[~2016-04-04  6:09 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 [this message]
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
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

  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=m3inzx6h2c.fsf@gnus.org \
    --to=larsi@gnus.org \
    --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).