unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
@ 2012-03-29 18:49 Aaron S. Hawley
  2012-03-29 20:17 ` Glenn Morris
  0 siblings, 1 reply; 12+ messages in thread
From: Aaron S. Hawley @ 2012-03-29 18:49 UTC (permalink / raw)
  To: 11127

2012-03-29  Aaron S. Hawley  <aaron.s.hawley@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
  2012-03-29 18:49 bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings Aaron S. Hawley
@ 2012-03-29 20:17 ` Glenn Morris
  2012-03-29 21:31   ` Aaron S. Hawley
  0 siblings, 1 reply; 12+ messages in thread
From: Glenn Morris @ 2012-03-29 20:17 UTC (permalink / raw)
  To: Aaron S. Hawley; +Cc: 11127

"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?





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
  2012-03-29 20:17 ` Glenn Morris
@ 2012-03-29 21:31   ` Aaron S. Hawley
  2012-03-30  3:58     ` Glenn Morris
  2012-03-30 17:23     ` Glenn Morris
  0 siblings, 2 replies; 12+ messages in thread
From: Aaron S. Hawley @ 2012-03-29 21:31 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 11127

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





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
  2012-03-29 21:31   ` Aaron S. Hawley
@ 2012-03-30  3:58     ` Glenn Morris
  2012-03-30 12:32       ` Stefan Monnier
  2012-03-30 17:23     ` Glenn Morris
  1 sibling, 1 reply; 12+ messages in thread
From: Glenn Morris @ 2012-03-30  3:58 UTC (permalink / raw)
  To: Aaron S. Hawley; +Cc: 11127

"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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
  2012-03-30  3:58     ` Glenn Morris
@ 2012-03-30 12:32       ` Stefan Monnier
  2012-03-30 16:20         ` Glenn Morris
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2012-03-30 12:32 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Aaron S. Hawley, 11127

> 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





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
  2012-03-30 12:32       ` Stefan Monnier
@ 2012-03-30 16:20         ` Glenn Morris
  2012-03-30 18:12           ` Aaron S. Hawley
  0 siblings, 1 reply; 12+ messages in thread
From: Glenn Morris @ 2012-03-30 16:20 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Aaron S. Hawley, 11127

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 ~).





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
  2012-03-29 21:31   ` Aaron S. Hawley
  2012-03-30  3:58     ` Glenn Morris
@ 2012-03-30 17:23     ` Glenn Morris
  1 sibling, 0 replies; 12+ messages in thread
From: Glenn Morris @ 2012-03-30 17:23 UTC (permalink / raw)
  To: Aaron S. Hawley; +Cc: 11127

"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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
  2012-03-30 16:20         ` Glenn Morris
@ 2012-03-30 18:12           ` Aaron S. Hawley
  2012-03-31 18:35             ` Glenn Morris
  0 siblings, 1 reply; 12+ messages in thread
From: Aaron S. Hawley @ 2012-03-30 18:12 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 11127

> 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)))





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
  2012-03-30 18:12           ` Aaron S. Hawley
@ 2012-03-31 18:35             ` Glenn Morris
  2012-04-02 13:28               ` Aaron S. Hawley
  2013-02-11  1:52               ` Glenn Morris
  0 siblings, 2 replies; 12+ messages in thread
From: Glenn Morris @ 2012-03-31 18:35 UTC (permalink / raw)
  To: Aaron S. Hawley; +Cc: 11127

"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".





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
  2012-03-31 18:35             ` Glenn Morris
@ 2012-04-02 13:28               ` Aaron S. Hawley
  2012-04-09 20:50                 ` Glenn Morris
  2013-02-11  1:52               ` Glenn Morris
  1 sibling, 1 reply; 12+ messages in thread
From: Aaron S. Hawley @ 2012-04-02 13:28 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 11127

On 3/31/12, Glenn Morris <rgm@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
  2012-04-02 13:28               ` Aaron S. Hawley
@ 2012-04-09 20:50                 ` Glenn Morris
  0 siblings, 0 replies; 12+ messages in thread
From: Glenn Morris @ 2012-04-09 20:50 UTC (permalink / raw)
  To: Aaron S. Hawley; +Cc: 11127

"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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings
  2012-03-31 18:35             ` Glenn Morris
  2012-04-02 13:28               ` Aaron S. Hawley
@ 2013-02-11  1:52               ` Glenn Morris
  1 sibling, 0 replies; 12+ messages in thread
From: Glenn Morris @ 2013-02-11  1:52 UTC (permalink / raw)
  To: 11127-done

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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-02-11  1:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-29 18:49 bug#11127: 24.0.94; [PATCH] Tutorial breaks with modified key bindings Aaron S. Hawley
2012-03-29 20:17 ` Glenn Morris
2012-03-29 21:31   ` Aaron S. Hawley
2012-03-30  3:58     ` Glenn Morris
2012-03-30 12:32       ` Stefan Monnier
2012-03-30 16:20         ` Glenn Morris
2012-03-30 18:12           ` Aaron S. Hawley
2012-03-31 18:35             ` Glenn Morris
2012-04-02 13:28               ` Aaron S. Hawley
2012-04-09 20:50                 ` Glenn Morris
2013-02-11  1:52               ` Glenn Morris
2012-03-30 17:23     ` Glenn Morris

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).