GNU bug report logs - #11127
24.0.94; [PATCH] Tutorial breaks with modified key bindings

Previous Next

Package: emacs;

Reported by: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>

Date: Thu, 29 Mar 2012 19:22:02 UTC

Severity: minor

Found in version 24.0.94

Fixed in version 24.4

Done: Glenn Morris <rgm <at> gnu.org>

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 11127 in the body.
You can then email your comments to 11127 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-gnu-emacs <at> gnu.org:
bug#11127; Package emacs. (Thu, 29 Mar 2012 19:22:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 29 Mar 2012 19:22:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
Date: Thu, 29 Mar 2012 14:49:33 -0400
2012-03-29  Aaron S. Hawley  <aaron.s.hawley <at> gmail.com>

        * tutorial.el (help-with-tutorial, tutorial--display-changes): If
        user has modified default key bindings then Emacs complains
        "Buffer is read-only: #<buffer TUTORIAL>" rather than adding the
        notice about "the most important standard Emacs commands".

--- tutorial.el	2012-02-13 11:13:25.000000000 -0500
+++ tutorial.el	2012-03-29 14:25:01.667926700 -0400
@@ -538,7 +538,8 @@
 If some of the default key bindings that the tutorial depends on
 have been changed then display the changes in the tutorial buffer
 with some explanatory links."
-  (let* ((changed-keys (tutorial--find-changed-keys
+  (let* ((inhibit-read-only t)
+         (changed-keys (tutorial--find-changed-keys
 			tutorial--default-keys))
 	 ;; Alist of element (DESC . CK) where DESC is the
 	 ;; key-description of a changed key and CK is the
@@ -828,7 +829,7 @@
           (setq old-tut-file
                 (y-or-n-p "Resume your last saved tutorial? ")))
         (if old-tut-file
-            (progn
+            (let ((inhibit-read-only t))
               (insert-file-contents (tutorial--saved-file))
 	      (let ((enable-local-variables :safe))
 		(hack-local-variables))
@@ -846,7 +847,8 @@
               (delete-region (point-min) (point))
               (goto-char tutorial--point-before-chkeys)
               (setq tutorial--point-before-chkeys (point-marker)))
-          (insert-file-contents (expand-file-name filename tutorial-directory))
+          (let ((inhibit-read-only t))
+            (insert-file-contents (expand-file-name filename
tutorial-directory)))
 	  (let ((enable-local-variables :safe))
 	    (hack-local-variables))
           (forward-line)
@@ -871,12 +873,14 @@
           ;; Delete the arch-tag line, so as not to confuse readers.
           (goto-char (point-max))
           (if (search-backward ";;; arch-tag: " nil t)
-              (delete-region (point) (point-max)))
+              (let ((inhibit-read-only t))
+                (delete-region (point) (point-max))))
           (goto-char (point-min))
           (search-forward "\n<<")
           (beginning-of-line)
           ;; Convert the <<...>> line to the proper [...] line,
           ;; or just delete the <<...>> line if a [...] line follows.
+          (let ((inhibit-read-only t))
           (cond ((save-excursion
                    (forward-line 1)
                    (looking-at "\\["))
@@ -887,18 +891,19 @@
                  (looking-at "<<")
                  (replace-match "[")
                  (search-forward ">>")
-                 (replace-match "]")))
+                 (replace-match "]"))))
           (beginning-of-line)
           ;; FIXME: if the window is not tall, and especially if the
           ;; big red "NOTICE: The main purpose..." text has been
           ;; inserted at the start of the buffer, the "type C-v to
           ;; move to the next screen" might not be visible on the
           ;; first screen (n < 0).  How will the novice know what to do?
-          (let ((n (- (window-height (selected-window))
+          (let ((inhibit-read-only t)
+                (n (- (window-height (selected-window))
                       (count-lines (point-min) (point))
                       6)))
             (if (< n 8)
-                (progn
+                (let ((inhibit-read-only t))
                   ;; For a short gap, we don't need the [...] line,
                   ;; so delete it.
                   (delete-region (point) (progn (end-of-line) (point)))

Thanks for Emacs,
aaron

-- 
In general, we reserve the right to have a poor
memory--the computer, however, is supposed to
remember!  Poor computer.  -- Guy Lewis Steele Jr.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11127; Package emacs. (Thu, 29 Mar 2012 20:50:02 GMT) Full text and rfc822 format available.

Message #8 received at 11127 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
Cc: 11127 <at> debbugs.gnu.org
Subject: Re: bug#11127: 24.0.94;
	[PATCH] Tutorial breaks with modified key bindings
Date: Thu, 29 Mar 2012 16:17:40 -0400
"Aaron S. Hawley" wrote:

>         * tutorial.el (help-with-tutorial, tutorial--display-changes): If
>         user has modified default key bindings then Emacs complains
>         "Buffer is read-only: #<buffer TUTORIAL>" rather than adding the
>         notice about "the most important standard Emacs commands".

I cannot reproduce this with the current trunk. I did:

emacs -Q
(global-set-key [?\C-f] 'ignore)
C-h t

The tutorial opens just fine:

    Emacs tutorial.  See end for copying conditions.

    NOTICE: The main purpose of the Emacs tutorial is to teach you
    the most important standard Emacs commands (key bindings).
    However, your Emacs has been customized by changing some of
    these basic editing commands, so it doesn't correspond to the
    tutorial.  We have inserted colored notices where the altered
    commands have been introduced. [More]

Why is your tutorial read-only?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11127; Package emacs. (Thu, 29 Mar 2012 22:04:02 GMT) Full text and rfc822 format available.

Message #11 received at 11127 <at> debbugs.gnu.org (full text, mbox):

From: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 11127 <at> debbugs.gnu.org
Subject: Re: bug#11127: 24.0.94;
	[PATCH] Tutorial breaks with modified key bindings
Date: Thu, 29 Mar 2012 17:31:31 -0400
Glenn Morris wrote:
> I cannot reproduce this with the current trunk. I did:
>
> emacs -Q
> (global-set-key [?\C-f] 'ignore)
> C-h t
>
> The tutorial opens just fine:
>
>     Emacs tutorial.  See end for copying conditions.
>
>     NOTICE: The main purpose of the Emacs tutorial is to teach you
>     the most important standard Emacs commands (key bindings).
>     However, your Emacs has been customized by changing some of
>     these basic editing commands, so it doesn't correspond to the
>     tutorial.  We have inserted colored notices where the altered
>     commands have been introduced. [More]
>
> Why is your tutorial read-only?

Glenn,

Sorry, should have tried -Q.  Turns out the tutorial was read-only
because I had dir-locals that set a directory to read-only and I
happened to run `C-h t' from that directory.

Try with,

    emacs -Q
    (dir-locals-set-class-variables
     'unwritable-directory
     '((nil . ((buffer-read-only . t)))))
    (dir-locals-set-directory-class default-directory 'unwritable-directory)
    C-h t

I believe I've found a corner-case.

Although, is (hack-local-variables) really that necessary in
tutorial.el?  It's not clear to me.
aaron




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11127; Package emacs. (Fri, 30 Mar 2012 04:30:01 GMT) Full text and rfc822 format available.

Message #14 received at 11127 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
Cc: 11127 <at> debbugs.gnu.org
Subject: Re: bug#11127: 24.0.94;
	[PATCH] Tutorial breaks with modified key bindings
Date: Thu, 29 Mar 2012 23:58:11 -0400
"Aaron S. Hawley" wrote:

>     (dir-locals-set-class-variables
>      'unwritable-directory
>      '((nil . ((buffer-read-only . t)))))
>     (dir-locals-set-directory-class default-directory 'unwritable-directory)
>     C-h t
>
> I believe I've found a corner-case.

A very small corner I should imagine. ;)
I'll make it set buffer-read-only (back) to nil after hacking locals.

Though maybe there are other directory locals that could cause
non-standard behaviour. It's a shame there appears to be no setting for
enable-local-variables that means "respect (safe) file-locals, but
ignore directory locals".

> Although, is (hack-local-variables) really that necessary in tutorial.el?

Some of the languages set sentence-end-double-space to nil.
That appears to be it. Personally, I think this takes "translation" a
bit too far, but without the local setting the sentence motion commands
don't work correctly. (Though I don't recall ever seeing this reported
as a bug, and prior to 24 local variables were not respected in the
tutorial.)

I also think any Local Variables section should be removed from the
displayed tutorial buffer.




Severity set to 'minor' from 'normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 30 Mar 2012 04:33:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11127; Package emacs. (Fri, 30 Mar 2012 13:05:02 GMT) Full text and rfc822 format available.

Message #19 received at 11127 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>, 11127 <at> debbugs.gnu.org
Subject: Re: bug#11127: 24.0.94;
	[PATCH] Tutorial breaks with modified key bindings
Date: Fri, 30 Mar 2012 08:32:18 -0400
> Though maybe there are other directory locals that could cause
> non-standard behaviour. It's a shame there appears to be no setting for
> enable-local-variables that means "respect (safe) file-locals, but
> ignore directory locals".

In the case of the tutorial, maybe we should use the tutorial's location
to initialize the default-directory setting, which would prevent it from
using the wrong dir-local settings.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11127; Package emacs. (Fri, 30 Mar 2012 16:53:01 GMT) Full text and rfc822 format available.

Message #22 received at 11127 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>, 11127 <at> debbugs.gnu.org
Subject: Re: bug#11127: 24.0.94;
	[PATCH] Tutorial breaks with modified key bindings
Date: Fri, 30 Mar 2012 12:20:28 -0400
Stefan Monnier wrote:

> In the case of the tutorial, maybe we should use the tutorial's location
> to initialize the default-directory setting, which would prevent it from
> using the wrong dir-local settings.

I'm not sure that will help with the specified example, where dir-locals
are applied by a class setting, not an actual file. Also, the tutorial
explains the use of C-x C-s, which implicitly relies on the directory
being writable (maybe it should actually set d-d to ~).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11127; Package emacs. (Fri, 30 Mar 2012 17:56:02 GMT) Full text and rfc822 format available.

Message #25 received at 11127 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
Cc: 11127 <at> debbugs.gnu.org
Subject: Re: bug#11127: 24.0.94;
	[PATCH] Tutorial breaks with modified key bindings
Date: Fri, 30 Mar 2012 13:23:46 -0400
"Aaron S. Hawley" wrote:

>     emacs -Q
>     (dir-locals-set-class-variables
>      'unwritable-directory
>      '((nil . ((buffer-read-only . t)))))
>     (dir-locals-set-directory-class default-directory 'unwritable-directory)

By the way, I know this example is partially taken fron the manual, but
I think I am going to say "don't do that", since it also affects some
non-file buffers, eg log-edit ones. Although you probably won't be
trying to commit a file from an unwritable directory anyway.
The more obvious sources of problems, eg dired and vc-dir, happen to
already make their buffers read-only.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11127; Package emacs. (Fri, 30 Mar 2012 18:14:27 GMT) Full text and rfc822 format available.

Message #28 received at 11127 <at> debbugs.gnu.org (full text, mbox):

From: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 11127 <at> debbugs.gnu.org
Subject: Re: bug#11127: 24.0.94;
	[PATCH] Tutorial breaks with modified key bindings
Date: Fri, 30 Mar 2012 14:12:54 -0400
> I'm not sure that will help with the specified example, where dir-locals
> are applied by a class setting, not an actual file.

My understanding is that all dir-locals classes need to apply to some
directory path.

> Also, the tutorial explains the use of C-x C-s, which implicitly relies
> on the directory being writable (maybe it should actually set d-d to ~).

Stefan's last comment made me wonder whether we could let-bind
`default-directory' to a bogus value that will never be a dir-locals
path.  How about the empty string?  This patch seems to work.  I
tested it with the same scenario before.

emacs -Q
(progn
  (dir-locals-set-class-variables
   'unwritable-directory
   '((nil . ((buffer-read-only . t)))))
  (dir-locals-set-directory-class default-directory 'unwritable-directory))
C-h t

--- tutorial.el	2012-02-13 11:13:25.000000000 -0500
+++ tutorial.el	2012-03-30 13:57:49.942206100 -0400
@@ -830,7 +830,8 @@
         (if old-tut-file
             (progn
               (insert-file-contents (tutorial--saved-file))
-	      (let ((enable-local-variables :safe))
+	      (let ((default-directory "")
+		    (enable-local-variables :safe))
 		(hack-local-variables))
               (goto-char (point-min))
               (setq old-tut-point
@@ -847,7 +848,8 @@
               (goto-char tutorial--point-before-chkeys)
               (setq tutorial--point-before-chkeys (point-marker)))
           (insert-file-contents (expand-file-name filename tutorial-directory))
-	  (let ((enable-local-variables :safe))
+	  (let ((default-directory "")
+		(enable-local-variables :safe))
 	    (hack-local-variables))
           (forward-line)
           (setq tutorial--point-before-chkeys (point-marker)))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11127; Package emacs. (Sat, 31 Mar 2012 18:36:01 GMT) Full text and rfc822 format available.

Message #31 received at 11127 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 11127 <at> debbugs.gnu.org
Subject: Re: bug#11127: 24.0.94;
	[PATCH] Tutorial breaks with modified key bindings
Date: Sat, 31 Mar 2012 14:35:01 -0400
"Aaron S. Hawley" wrote:

> +	      (let ((default-directory "")
> +		    (enable-local-variables :safe))

I'd rather have an explicit enable-dir-local-variables variable.

Also, I think there should probably some way in a dir-locals file to say
"these settings should only be applied to buffers with files".




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11127; Package emacs. (Mon, 02 Apr 2012 13:29:02 GMT) Full text and rfc822 format available.

Message #34 received at 11127 <at> debbugs.gnu.org (full text, mbox):

From: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 11127 <at> debbugs.gnu.org
Subject: Re: bug#11127: 24.0.94;
	[PATCH] Tutorial breaks with modified key bindings
Date: Mon, 2 Apr 2012 09:28:36 -0400
On 3/31/12, Glenn Morris <rgm <at> gnu.org> wrote:
> "Aaron S. Hawley" wrote:
>
>> +	      (let ((default-directory "")
>> +		    (enable-local-variables :safe))
>
> I'd rather have an explicit enable-dir-local-variables variable.

I agree.

> Also, I think there should probably some way in a dir-locals file to say
> "these settings should only be applied to buffers with files".

I believe it is the case already that dir-locals only applies to
buffers associated with files.  It's only because tutorial.el calls
`hack-local-variables' that it applies here.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11127; Package emacs. (Mon, 09 Apr 2012 20:52:01 GMT) Full text and rfc822 format available.

Message #37 received at 11127 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 11127 <at> debbugs.gnu.org
Subject: Re: bug#11127: 24.0.94;
	[PATCH] Tutorial breaks with modified key bindings
Date: Mon, 09 Apr 2012 16:50:07 -0400
"Aaron S. Hawley" wrote:

>> Also, I think there should probably some way in a dir-locals file to say
>> "these settings should only be applied to buffers with files".
>
> I believe it is the case already that dir-locals only applies to
> buffers associated with files.  It's only because tutorial.el calls
> `hack-local-variables' that it applies here.

It also applies to some file-less buffers, such as vc-dir.
This is by design, such buffers manually hack the dir-locals.




Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Mon, 11 Feb 2013 01:53:02 GMT) Full text and rfc822 format available.

Notification sent to "Aaron S. Hawley" <aaron.s.hawley <at> gmail.com>:
bug acknowledged by developer. (Mon, 11 Feb 2013 01:53:02 GMT) Full text and rfc822 format available.

Message #42 received at 11127-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 11127-done <at> debbugs.gnu.org
Subject: Re: bug#11127: 24.0.94;
	[PATCH] Tutorial breaks with modified key bindings
Date: Sun, 10 Feb 2013 20:52:18 -0500
Version: 24.4

Glenn Morris wrote:

> I'd rather have an explicit enable-dir-local-variables variable.

Added.

> Also, I think there should probably some way in a dir-locals file to say
> "these settings should only be applied to buffers with files".

Will open wishlist for this.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 11 Mar 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 53 days ago.

Previous Next


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