emacs-devel
[Top][All Lists]
Advanced

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

Re: Proposal: `buffer-offer-save' be made a permanent-local


From: MON KEY
Subject: Re: Proposal: `buffer-offer-save' be made a permanent-local
Date: Thu, 17 Jun 2010 20:13:38 -0400

On Thu, Jun 17, 2010 at 6:25 PM, Lennart Borgman
<address@hidden> wrote:
>
> Is not this just a misuse of a feature? You can misuse any feature.
>

NO! If the elisp API exposes permanent-local it isn't a misuse it is
to be expected that people will use it (whether you or I agree with
such use or not).

The `misuse' of permanent-local is the ad hoc elevation of only _some_
symbols to permanent local status.

Let all symbols be permanent permanent local by default or stop adding
them arbitrarily to satisfy a kludge.

> And this has nothing to do with the change I proposed.

It most certainly does.

Kevin's query illustrates that where persisting state in a buffer is
merely a matter of putting some permanent property on the buffer this
is trivially accomplished. Its not at all unlike a web-browser setting
a session cookie to hold state (and approximately as unclean).

> Instead, as I said before (a bit less explicit) it rather has to do
> with complexity.

Nonsense, the complexity is an outcome of a series of simplistic
solution being thrown at the problem.

Someone might just as well ask why not use a delimited continuation or
closure based protocol to hold these kinds of state instead if its
such a complex situation? Alas, you can't stop a cookie monster :)

> Your major mode is simply not expected to to this kind of things.

This is exactly my point. They will do it.  And your proposal is to
have this behaviour explicitly blessed.

>
> And this has nothing to do with the change I proposed.
>
Why not?

Couldn't you accomplish a major-moded state change by doing something
like this:

(put 'dead-weight-unless-you-look-for-me 'permanent-local t)

(with-current-buffer (current-buffer)
  (set (make-local-variable 'dead-weight-unless-you-look-for-me) t))

;; (unintern 'dead-weight-unless-you-look-for-me)
(setplist 'dead-weight-unless-you-look-for-me
          `(,(get-buffer (current-buffer))
            (:buffer-offer-save t)))

(with-current-buffer (get-buffer (other-buffer))
  (buffer-local-value
   (intern-soft "dead-weight-unless-you-look-for-me")
   (current-buffer)))
;; => void over there

(buffer-local-value
 (intern-soft "dead-weight-unless-you-look-for-me")
 (current-buffer))
;; => t over here

(get
 (intern-soft "dead-weight-unless-you-look-for-me")
 (get-buffer (current-buffer)))
;; => (:buffer-offer-save t)

(get (intern-soft "dead-weight-unless-you-look-for-me")
     (get-buffer (current-buffer)))
;=> (:buffer-offer-save t)

(plist-get
 (get (intern-soft "dead-weight-unless-you-look-for-me")
 (get-buffer (current-buffer)))
             :buffer-offer-save)
;=> (:buffer-offer-save t)

(fundamental-mode)

(plist-get
 (get (intern-soft "dead-weight-unless-you-look-for-me")
      (get-buffer (current-buffer)))
 :buffer-offer-save)
; => t

(emacs-lisp-mode)

(plist-get
 (get (intern-soft "dead-weight-unless-you-look-for-me")
      (get-buffer (current-buffer)))
 :buffer-offer-save)
;=> t

(fundamental-mode)

(plist-get
 (get (intern-soft "dead-weight-unless-you-look-for-me")
      (get-buffer (current-buffer)))
 :buffer-offer-save)
;=> t

(with-current-buffer (get-buffer (other-buffer))
  (buffer-local-value
   (intern-soft "dead-weight-unless-you-look-for-me")
   (current-buffer)))
;=> still void.

--
/s_P\



reply via email to

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