GNU bug report logs - #1013
23.0.60; permanent-local not honored for word-wrap

Previous Next

Package: emacs;

Reported by: "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>

Date: Sun, 21 Sep 2008 20:40:04 UTC

Severity: normal

Done: "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 1013 in the body.
You can then email your comments to 1013 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1013; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.0.60; permanent-local not honored for word-wrap
Date: Sun, 21 Sep 2008 22:31:49 +0200
In a new buffer evaluate this:

  (put 'word-wrap 'permanent-local t)
  (setq word-wrap t)
  (kill-all-local-variables)

and then look at word-wrap. It is nil, but it should be t.


In GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600)
 of 2008-09-18
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --no-opt --cflags
-Ic:/g/include -fno-crossjumping'





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1013; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #10 received at 1013 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
To: 1013 <at> debbugs.gnu.org
Subject: Re: bug#1013: 23.0.60; permanent-local not honored for word-wrap
Date: Mon, 22 Sep 2008 00:25:29 +0200
[Message part 1 (text/plain, inline)]
I played a bit with making a unit test for this, see the attached file.
This requires the ert2.el that comes with nXhtml and should be placed in
the same subdir as nxhtmltest-suites.el.

[emacstest-suites.el (text/plain, inline)]
;;; emacstest-suites.el --- Some unit tests for Emacs
;;
;; Author: Lennart Borgman (lennart O borgman A gmail O com)
;; Created: 2008-09-21T22:34:11+0200 Sun
;; Version:
;; Last-Updated:
;; URL:
;; Keywords:
;; Compatibility:
;;
;; Features that might be required by this library:
;;
;;   None
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; Unit tests for some Emacs bug reports.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change log:
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:

(eval-when-compile (require 'cl))

(setq debug-on-error t)

(defvar emacstest-bin
  (file-name-directory (if load-file-name load-file-name buffer-file-name)))

(pushnew emacstest-bin load-path)
(require 'ert2)


(defvar emacstest-files-root
  (let* ((this-dir emacstest-bin)
         (root (expand-file-name "inemacs/" this-dir)))
    (unless (file-accessible-directory-p root)
          (error (if (file-exists-p root)
                     "Can't read files in test directory %s"
                   "Can't find test directory %s")
                 root))
    root))

(let ((distr-in "c:/EmacsW32/nxhtml/tests/inemacs/"))
  (when (file-directory-p distr-in)
    (setq nxhtmltest-files-root distr-in)))

(ert-deftest emacs-bug1013 ()
  "Emacs bug 1013.
See URL
`http://debbugs.gnu.org/cgi/bugreport.cgi?bug=1013'."
  (with-temp-buffer
    (insert "
      (defvar word-wrap2 nil)
      (make-variable-buffer-local 'word-wrap2)
      (defcustom word-wrap3 nil
        \"doc 3\"
        :type 'boolean)
      (make-variable-buffer-local 'word-wrap3)
      (put 'word-wrap  'permanent-local t)
      (put 'word-wrap2 'permanent-local t)
      (put 'word-wrap3 'permanent-local t)
      (setq word-wrap t)
      (setq word-wrap2 t)
      (setq word-wrap3 t)
      (kill-all-local-variables)")
    (eval-buffer)
    (ert-should (eq word-wrap3 t))
    (ert-should (eq word-wrap2 t))
    (ert-should (eq word-wrap t))
    ))

(provide 'emacstest-suites)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; emacstest-suites.el ends here

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1013; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #15 received at 1013 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
To: 1013 <at> debbugs.gnu.org,
        Christian Ohler <ohler+emacs <at> fastmail.net>
Cc: Phil Hagelberg <phil <at> hagelb.org>
Subject: Re: bug#1013: 23.0.60; permanent-local not honored for word-wrap
Date: Mon, 22 Sep 2008 01:13:17 +0200
[Message part 1 (text/plain, inline)]
Lennart Borgman (gmail) wrote:
> I played a bit with making a unit test for this, see the attached file.
> This requires the ert2.el that comes with nXhtml and should be placed in
> the same subdir as nxhtmltest-suites.el.

Here is a much better way to structure the test. To test it:

- Put emacstest-suites.el in nxhtml/test/
- Put bug1013.el in nxhtml/test/inemacs/
- M-x emacstest-run

If we include ert.el + ert2.el in Emacs we could write unit tests like
this for bug reports.

Christian, any thoughts?
[emacstest-suites.el (text/plain, inline)]
;;; emacstest-suites.el --- Some unit tests for Emacs
;;
;; Author: Lennart Borgman (lennart O borgman A gmail O com)
;; Created: 2008-09-21T22:34:11+0200 Sun
;; Version:
;; Last-Updated: 2008-09-22T00:36:11+0200 Sun
;; URL:
;; Keywords:
;; Compatibility:
;;
;; Features that might be required by this library:
;;
;;   `button', `cl', `debug', `ert', `ert2', `ewoc', `find-func',
;;   `help-fns', `help-mode', `view'.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; Unit tests for some Emacs bug reports.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Change log:
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:

(eval-when-compile (require 'cl))

(setq debug-on-error t)

(defvar emacstest-bin
  (file-name-directory (if load-file-name load-file-name buffer-file-name)))

(pushnew emacstest-bin load-path)
(require 'ert2)


(defvar emacstest-files-root
  (let* ((this-dir emacstest-bin)
         (root (expand-file-name "inemacs/" this-dir)))
    (unless (file-accessible-directory-p root)
          (error (if (file-exists-p root)
                     "Can't read files in test directory %s"
                   "Can't find test directory %s")
                 root))
    root))

(let ((distr-in "c:/EmacsW32/nxhtml/tests/inemacs/"))
  (when (file-directory-p distr-in)
    (setq emacstest-files-root distr-in)))

(defun emacstest-run ()
  "Run Emacs tests."
  (interactive)
  (setq message-log-max t)
  (setq ert-test-files-root emacstest-files-root)
  (let ((selector "emacs-"))
    (if noninteractive
        (ert-run-tests-batch selector)
      (ert-kill-temp-test-buffers)
      (ert-run-tests-interactively selector)
      (other-window 1)
      (ert-list-temp-test-buffers))))

(ert-deftest emacs-bug1013 ()
  "Emacs bug 1013.
See URL
`http://debbugs.gnu.org/cgi/bugreport.cgi?bug=1013'."
  (ert-with-temp-buffer-include-file "bug1013.el"
    (eval-buffer)))

(provide 'emacstest-suites)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; emacstest-suites.el ends here
[bug1013.el (text/plain, inline)]
;; Setup
(defvar word-wrap2 nil)
(make-variable-buffer-local 'word-wrap2)
(set-default 'word-wrap2 nil)

(defcustom word-wrap3 nil
  "doc 3"
  :type 'boolean)
(make-variable-buffer-local 'word-wrap3)
(set-default 'word-wrap3 nil)

(set-default 'word-wrap nil)

(put 'word-wrap  'permanent-local t)
(put 'word-wrap2 'permanent-local t)
(put 'word-wrap3 'permanent-local t)

(setq word-wrap t)
(setq word-wrap2 t)
(setq word-wrap3 t)

(kill-all-local-variables)
;; Test
(ert-should (eq (default-value 'word-wrap3) nil))
(ert-should (eq word-wrap3 t))
(ert-should (eq (default-value 'word-wrap2) nil))
(ert-should (eq word-wrap2 t))
(ert-should (eq (default-value 'word-wrap) nil))
(ert-should (eq word-wrap t))

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>:
bug acknowledged by developer. Full text and rfc822 format available.

Message #20 received at 1013-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: "Lennart Borgman \(gmail\)" <lennart.borgman <at> gmail.com>
Cc: 1013-done <at> debbugs.gnu.org
Subject: Re: bug#1013: 23.0.60; permanent-local not honored for word-wrap
Date: Sun, 21 Sep 2008 23:26:15 -0400
>   (put 'word-wrap 'permanent-local t)
>   (setq word-wrap t)
>   (kill-all-local-variables)

> and then look at word-wrap. It is nil, but it should be t.

Why should it?  word-wrap is automatically made local, so the `setq' is
really like (set (make-local-variable 'word-wrap) t), thus not changing
the global value at which is you'll be looking in the end.


        Stefan




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1013; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #25 received at 1013 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 1013 <at> debbugs.gnu.org
Subject: Re: bug#1013: 23.0.60; permanent-local not honored for word-wrap
Date: Mon, 22 Sep 2008 20:11:29 +0200
Stefan Monnier wrote:
> reopen 1013
> thanks
> 
>> I just tested with truncate-lines. Same bug as with word-wrap.
> 
>> Both `word-wrap' and `truncate-lines' are defined using
>> DEFVAR_PER_BUFFER. My guess is that there is a bug in DEFVAR_PER_BUFFER
>> or something related to that.
> 
> Duh, sorry I misread kill-local-variable for kill-all-local-variables
> (i.e. I didn't read what you wrote, but what I thought you'd written).
> 
> Yes, it's a problem with the variables defined by DEFVAR_PER_BUFFER.
> Their semantics is subtly different from the ones declared with
> make-variable-buffer-local.


Thanks. Are there any principal reason that 'permanent-local is not honored?

BTW: Should not variables like `word-wrap' be permanent-local by
default? It looks to me like they are more "per buffer/file" than "per
major mode".




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1013; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #30 received at 1013 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: "Lennart Borgman \(gmail\)" <lennart.borgman <at> gmail.com>
Cc: 1013 <at> debbugs.gnu.org, control <at> debbugs.gnu.org
Subject: Re: bug#1013: 23.0.60; permanent-local not honored for word-wrap
Date: Mon, 22 Sep 2008 13:38:04 -0400
reopen 1013
thanks

> I just tested with truncate-lines. Same bug as with word-wrap.

> Both `word-wrap' and `truncate-lines' are defined using
> DEFVAR_PER_BUFFER. My guess is that there is a bug in DEFVAR_PER_BUFFER
> or something related to that.

Duh, sorry I misread kill-local-variable for kill-all-local-variables
(i.e. I didn't read what you wrote, but what I thought you'd written).

Yes, it's a problem with the variables defined by DEFVAR_PER_BUFFER.
Their semantics is subtly different from the ones declared with
make-variable-buffer-local.


        Stefan




bug reopened, originator not changed. Request was from Stefan Monnier <monnier <at> IRO.UMontreal.CA> to control <at> emacsbugs.donarmstrong.com. (Tue, 23 Sep 2008 04:30:07 GMT) Full text and rfc822 format available.

Reply sent to "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>:
bug acknowledged by developer. Full text and rfc822 format available.

Message #37 received at 1013-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 1013-done <at> debbugs.gnu.org
Subject: Re: bug#1013: 23.0.60; permanent-local not honored for word-wrap
Date: Mon, 22 Sep 2008 16:37:22 +0200
Stefan Monnier wrote:
>>   (put 'word-wrap 'permanent-local t)
>>   (setq word-wrap t)
>>   (kill-all-local-variables)
> 
>> and then look at word-wrap. It is nil, but it should be t.
> 
> Why should it?  word-wrap is automatically made local, so the `setq' is
> really like (set (make-local-variable 'word-wrap) t), thus not changing
> the global value at which is you'll be looking in the end.


I just tested with truncate-lines. Same bug as with word-wrap.

Both `word-wrap' and `truncate-lines' are defined using
DEFVAR_PER_BUFFER. My guess is that there is a bug in DEFVAR_PER_BUFFER
or something related to that.

Stefan, could it be that you forgot about `permanent-local' when you
implemented this?




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1013; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #42 received at 1013 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 1013 <at> debbugs.gnu.org,
        "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
Subject: Re: bug#1013: marked as done (23.0.60; permanent-local not honored
  for word-wrap)
Date: Mon, 22 Sep 2008 17:59:22 +0200
>>   (put 'word-wrap 'permanent-local t)
>>   (setq word-wrap t)
>>   (kill-all-local-variables)
>
>> and then look at word-wrap. It is nil, but it should be t.
>
> Why should it?  word-wrap is automatically made local, so the `setq' is
> really like (set (make-local-variable 'word-wrap) t), thus not changing
> the global value at which is you'll be looking in the end.

Presumably Lennart wants to preserve the previous value when he changes
the major mode.  IIUC it is reset because buffer_permanent_local_flags
is 0 for word_wrap.  But I'm not sure whether that's TRT and I didn't
find any documentation for this behavior either.

martin




Message #43 received at 1013-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 1013-done <at> debbugs.gnu.org
Subject: Re: bug#1013: 23.0.60; permanent-local not honored for word-wrap
Date: Mon, 22 Sep 2008 08:42:54 +0200
Stefan Monnier wrote:
>>   (put 'word-wrap 'permanent-local t)
>>   (setq word-wrap t)
>>   (kill-all-local-variables)
> 
>> and then look at word-wrap. It is nil, but it should be t.
> 
> Why should it?  word-wrap is automatically made local, so the `setq' is
> really like (set (make-local-variable 'word-wrap) t), thus not changing
> the global value at which is you'll be looking in the end.

Is there something I am missing? The three variables below are all
automatically buffer local, they are all three `permanent-local, but
only `word-wrap' looses it buffer local value? (Only the last test below
fails.)

From (info "(elisp) Creating Buffer-Local"):

   A buffer-local variable is "permanent" if the variable name (a
   symbol) has a `permanent-local' property that is non-`nil'.

==== Here is the test file again ===
;; Setup
(defvar word-wrap2 nil)
(make-variable-buffer-local 'word-wrap2)
(set-default 'word-wrap2 nil)

(defcustom word-wrap3 nil
  "doc 3"
  :type 'boolean)
(make-variable-buffer-local 'word-wrap3)
(set-default 'word-wrap3 nil)

(set-default 'word-wrap nil)

(put 'word-wrap  'permanent-local t)
(put 'word-wrap2 'permanent-local t)
(put 'word-wrap3 'permanent-local t)

(setq word-wrap t)
(setq word-wrap2 t)
(setq word-wrap3 t)

(kill-all-local-variables)

;; Test
(ert-should (eq (default-value 'word-wrap3) nil))
(ert-should (eq word-wrap3 t))
(ert-should (eq (default-value 'word-wrap2) nil))
(ert-should (eq word-wrap2 t))
(ert-should (eq (default-value 'word-wrap) nil))
(ert-should (eq word-wrap t))




bug archived. Request was from Debbugs Internal Request <don <at> donarmstrong.com> to internal_control <at> emacsbugs.donarmstrong.com. (Tue, 21 Oct 2008 14:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 16 years and 246 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.