diff options
| author | Stefan Monnier | 2013-06-25 09:07:04 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-06-25 09:07:04 -0400 |
| commit | c763842b8826d8adffed581838fd73c616686d1a (patch) | |
| tree | 59b8a93137808fb45892acb8eefac03dddf87972 | |
| parent | bceff1894c0ec2c7f47cd09bed4d94fbaa2a7ea6 (diff) | |
| download | emacs-c763842b8826d8adffed581838fd73c616686d1a.tar.gz emacs-c763842b8826d8adffed581838fd73c616686d1a.zip | |
* lisp/files-x.el (read-file-local-variable-value): Use read-from-minibuffer
for values and use read--expression for expressions.
(read-file-local-variable): Avoid setq.
(read-file-local-variable-mode): Use minor-mode-list.
Fixes: debbugs:14710
| -rw-r--r-- | lisp/ChangeLog | 17 | ||||
| -rw-r--r-- | lisp/files-x.el | 75 |
2 files changed, 49 insertions, 43 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7376fc31af4..864822bed20 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-06-25 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * files-x.el (read-file-local-variable-value): Use read-from-minibuffer | ||
| 4 | for values and use read--expression for expressions (bug#14710). | ||
| 5 | (read-file-local-variable): Avoid setq. | ||
| 6 | (read-file-local-variable-mode): Use minor-mode-list. | ||
| 7 | |||
| 1 | 2013-06-25 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de> | 8 | 2013-06-25 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de> |
| 2 | 9 | ||
| 3 | * lisp/textmodes/bibtex.el (bibtex-generate-url-list): Add support | 10 | * lisp/textmodes/bibtex.el (bibtex-generate-url-list): Add support |
| @@ -31,7 +38,7 @@ | |||
| 31 | * net/shr.el (shr-browse-url): Use an external browser if given a | 38 | * net/shr.el (shr-browse-url): Use an external browser if given a |
| 32 | prefix. | 39 | prefix. |
| 33 | 40 | ||
| 34 | * net/eww.el (eww-external-browser): Moved to shr. | 41 | * net/eww.el (eww-external-browser): Move to shr. |
| 35 | 42 | ||
| 36 | 2013-06-24 Ivan Kanis <ivan@kanis.fr> | 43 | 2013-06-24 Ivan Kanis <ivan@kanis.fr> |
| 37 | 44 | ||
| @@ -119,8 +126,8 @@ | |||
| 119 | 126 | ||
| 120 | 2013-06-21 Dmitry Gutov <dgutov@yandex.ru> | 127 | 2013-06-21 Dmitry Gutov <dgutov@yandex.ru> |
| 121 | 128 | ||
| 122 | * progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight | 129 | * progmodes/ruby-mode.el (ruby-font-lock-keywords): |
| 123 | keyword-like methods on Kernel and Module with | 130 | Highlight keyword-like methods on Kernel and Module with |
| 124 | font-lock-builtin-face. | 131 | font-lock-builtin-face. |
| 125 | (auto-mode-alist): Consolidate different entries into one regexp | 132 | (auto-mode-alist): Consolidate different entries into one regexp |
| 126 | and add more *file-s. | 133 | and add more *file-s. |
| @@ -606,8 +613,8 @@ | |||
| 606 | 613 | ||
| 607 | 2013-06-19 Michael Albinus <michael.albinus@gmx.de> | 614 | 2013-06-19 Michael Albinus <michael.albinus@gmx.de> |
| 608 | 615 | ||
| 609 | * net/secrets.el (secrets-struct-secret-content-type): Replace | 616 | * net/secrets.el (secrets-struct-secret-content-type): |
| 610 | check of introspection data by a test call of "CreateItem". | 617 | Replace check of introspection data by a test call of "CreateItem". |
| 611 | Some servers do not offer introspection. | 618 | Some servers do not offer introspection. |
| 612 | 619 | ||
| 613 | 2013-06-19 Stefan Monnier <monnier@iro.umontreal.ca> | 620 | 2013-06-19 Stefan Monnier <monnier@iro.umontreal.ca> |
diff --git a/lisp/files-x.el b/lisp/files-x.el index 6864e9a7b14..072eebece80 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el | |||
| @@ -38,11 +38,10 @@ | |||
| 38 | Intended to be used in the `interactive' spec of | 38 | Intended to be used in the `interactive' spec of |
| 39 | `add-file-local-variable', `delete-file-local-variable', | 39 | `add-file-local-variable', `delete-file-local-variable', |
| 40 | `add-dir-local-variable', `delete-dir-local-variable'." | 40 | `add-dir-local-variable', `delete-dir-local-variable'." |
| 41 | (let (default variable) | 41 | (let* ((default (variable-at-point)) |
| 42 | (setq default (variable-at-point)) | 42 | (default (and (symbolp default) (boundp default) |
| 43 | (setq default (and (symbolp default) (boundp default) | ||
| 44 | (symbol-name default))) | 43 | (symbol-name default))) |
| 45 | (setq variable | 44 | (variable |
| 46 | (completing-read | 45 | (completing-read |
| 47 | (if default | 46 | (if default |
| 48 | (format "%s (default %s): " prompt default) | 47 | (format "%s (default %s): " prompt default) |
| @@ -52,48 +51,46 @@ Intended to be used in the `interactive' spec of | |||
| 52 | (or (custom-variable-p sym) | 51 | (or (custom-variable-p sym) |
| 53 | (get sym 'safe-local-variable) | 52 | (get sym 'safe-local-variable) |
| 54 | (memq sym '(mode eval coding unibyte)))) | 53 | (memq sym '(mode eval coding unibyte)))) |
| 55 | nil nil nil default nil)) | 54 | nil nil nil default nil))) |
| 56 | (and (stringp variable) (intern variable)))) | 55 | (and (stringp variable) (intern variable)))) |
| 57 | 56 | ||
| 58 | (defun read-file-local-variable-value (variable) | 57 | (defun read-file-local-variable-value (variable) |
| 59 | "Read value of file-local VARIABLE using completion. | 58 | "Read value of file-local VARIABLE using completion. |
| 60 | Intended to be used in the `interactive' spec of | 59 | Intended to be used in the `interactive' spec of |
| 61 | `add-file-local-variable' and `add-dir-local-variable'." | 60 | `add-file-local-variable' and `add-dir-local-variable'." |
| 62 | (let (default value) | 61 | (cond |
| 63 | (cond | 62 | ((eq variable 'mode) |
| 64 | ((eq variable 'mode) | 63 | (let* ((default (and (symbolp major-mode) (symbol-name major-mode))) |
| 65 | (setq default (and (symbolp major-mode) (symbol-name major-mode))) | 64 | (value |
| 66 | (setq value | 65 | (completing-read |
| 67 | (completing-read | 66 | (if default |
| 68 | (if default | 67 | (format "Add %s with value (default %s): " variable default) |
| 69 | (format "Add %s with value (default %s): " variable default) | 68 | (format "Add %s with value: " variable)) |
| 70 | (format "Add %s with value: " variable)) | 69 | obarray |
| 71 | obarray | 70 | (lambda (sym) |
| 72 | (lambda (sym) | 71 | (string-match-p "-mode\\'" (symbol-name sym))) |
| 73 | (string-match-p "-mode\\'" (symbol-name sym))) | 72 | nil nil nil default nil))) |
| 74 | nil nil nil default nil)) | ||
| 75 | (and (stringp value) | 73 | (and (stringp value) |
| 76 | (intern (replace-regexp-in-string "-mode\\'" "" value)))) | 74 | (intern (replace-regexp-in-string "-mode\\'" "" value))))) |
| 77 | ((eq variable 'eval) | 75 | ((eq variable 'eval) |
| 78 | (let ((minibuffer-completing-symbol t)) | 76 | (read--expression (format "Add %s with expression: " variable))) |
| 79 | (read-from-minibuffer (format "Add %s with expression: " variable) | 77 | ((eq variable 'coding) |
| 80 | nil read-expression-map t | 78 | (let ((default (and (symbolp buffer-file-coding-system) |
| 81 | 'read-expression-history))) | 79 | (symbol-name buffer-file-coding-system)))) |
| 82 | ((eq variable 'coding) | ||
| 83 | (setq default (and (symbolp buffer-file-coding-system) | ||
| 84 | (symbol-name buffer-file-coding-system))) | ||
| 85 | (read-coding-system | 80 | (read-coding-system |
| 86 | (if default | 81 | (if default |
| 87 | (format "Add %s with value (default %s): " variable default) | 82 | (format "Add %s with value (default %s): " variable default) |
| 88 | (format "Add %s with value: " variable)) | 83 | (format "Add %s with value: " variable)) |
| 89 | default)) | 84 | default))) |
| 90 | (t | 85 | (t |
| 91 | (read (read-string (format "Add %s with value: " variable) | 86 | (let ((default (format "%S" |
| 92 | nil 'set-variable-value-history | 87 | (cond ((eq variable 'unibyte) t) |
| 93 | (format "%S" | 88 | ((boundp variable) |
| 94 | (cond ((eq variable 'unibyte) t) | 89 | (symbol-value variable))))) |
| 95 | ((boundp variable) | 90 | (minibuffer-completing-symbol t)) |
| 96 | (symbol-value variable)))))))))) | 91 | (read-from-minibuffer (format "Add %s with value: " variable) |
| 92 | nil read-expression-map t | ||
| 93 | 'set-variable-value-history))))) | ||
| 97 | 94 | ||
| 98 | (defun read-file-local-variable-mode () | 95 | (defun read-file-local-variable-mode () |
| 99 | "Read per-directory file-local variable's mode using completion. | 96 | "Read per-directory file-local variable's mode using completion. |
| @@ -108,7 +105,9 @@ Intended to be used in the `interactive' spec of | |||
| 108 | obarray | 105 | obarray |
| 109 | (lambda (sym) | 106 | (lambda (sym) |
| 110 | (and (string-match-p "-mode\\'" (symbol-name sym)) | 107 | (and (string-match-p "-mode\\'" (symbol-name sym)) |
| 111 | (not (string-match-p "-minor-mode\\'" (symbol-name sym))))) | 108 | (not (or (memq sym minor-mode-list) |
| 109 | (string-match-p "-minor-mode\\'" | ||
| 110 | (symbol-name sym)))))) | ||
| 112 | nil nil nil default nil))) | 111 | nil nil nil default nil))) |
| 113 | (cond | 112 | (cond |
| 114 | ((equal mode "nil") nil) | 113 | ((equal mode "nil") nil) |