From c4151ebe15479de4c2e511b068cdf9af6a4576cf Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 19 Jun 2015 00:35:43 -0700 Subject: Improve the optional translation of quotes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix several problems with the recently-added custom variable help-quote-translation where the code would quote inconsistently in help buffers. Add support for quoting 'like this', which is common in other GNU programs in ASCII environments. Change help-quote-translation to use more mnemonic values: values are now the initial quoting char, e.g., (setq help-quote-translation ?`) gets the traditional Emacs help-buffer quoting style `like this'. Change the default behavior of substitute-command-keys to match what's done in set-locale-environment, i.e., quote ‘like this’ if displayable, 'like this' otherwise. * doc/lispref/help.texi (Keys in Documentation): Document new behavior of substitute-command-keys, and document help-quote-translation. * doc/lispref/tips.texi (Documentation Tips): Mention the effect of help-quote-translation. * etc/NEWS: Mention new behavior of substitute-command-keys, and merge help-quote-translation news into it. When talking about doc strings, mention new ways to type quotes. * lisp/cedet/mode-local.el (overload-docstring-extension): Revert my recent change to this function, which shouldn't be needed as the result is a doc string. * lisp/cedet/mode-local.el (mode-local-print-binding) (mode-local-describe-bindings-2): * lisp/cedet/srecode/srt-mode.el (srecode-macro-help): * lisp/cus-theme.el (describe-theme-1): * lisp/descr-text.el (describe-text-properties-1, describe-char): * lisp/emacs-lisp/cl-generic.el (cl--generic-describe): * lisp/emacs-lisp/eieio-opt.el (eieio-help-class) (eieio-help-constructor): * lisp/emacs-lisp/package.el (describe-package-1): * lisp/faces.el (describe-face): * lisp/help-fns.el (help-fns--key-bindings) (help-fns--compiler-macro, help-fns--parent-mode) (help-fns--obsolete, help-fns--interactive-only) (describe-function-1, describe-variable): * lisp/help.el (describe-mode): Use substitute-command-keys to ensure a more-consistent quoting style in help buffers. * lisp/cus-start.el (standard): Document new help-quote-translation behavior. * lisp/emacs-lisp/lisp-mode.el (lisp-fdefs): * lisp/help-mode.el (help-xref-symbol-regexp, help-xref-info-regexp) (help-xref-url-regexp): * lisp/international/mule-cmds.el (help-xref-mule-regexp-template): * lisp/wid-edit.el (widget-documentation-link-regexp): Also match 'foo', in case we're in a help buffer generated when help-quote-translation is ?'. * src/doc.c: Include disptab.h, for DISP_CHAR_VECTOR. (LEFT_SINGLE_QUOTATION_MARK, uLSQM0, uLSQM1, uLSQM2, uRSQM0) (uRSQM1, uRSQM2, LSQM, RSQM): New constants. (Fsubstitute_command_keys): Document and implement new behavior. (Vhelp_quote_translation): Document new behavior. --- lisp/emacs-lisp/cl-generic.el | 4 ++-- lisp/emacs-lisp/eieio-opt.el | 20 ++++++++++---------- lisp/emacs-lisp/lisp-mode.el | 8 ++++---- lisp/emacs-lisp/package.el | 7 ++++--- 4 files changed, 20 insertions(+), 19 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index 96b86aa21cc..5923e4db996 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -876,11 +876,11 @@ Can only be used from within the lexical body of a primary or around method." (cl--generic-method-specializers method))) (file (find-lisp-object-file-name met-name 'cl-defmethod))) (when file - (insert " in ‘") + (insert (substitute-command-keys " in ‘")) (help-insert-xref-button (help-fns-short-filename file) 'help-function-def met-name file 'cl-defmethod) - (insert "’.\n"))) + (insert (substitute-command-keys "’.\n")))) (insert "\n" (or (nth 2 info) "Undocumented") "\n\n"))))))) ;;; Support for (head ) specializers. diff --git a/lisp/emacs-lisp/eieio-opt.el b/lisp/emacs-lisp/eieio-opt.el index 11d99849a97..6cd6813956a 100644 --- a/lisp/emacs-lisp/eieio-opt.el +++ b/lisp/emacs-lisp/eieio-opt.el @@ -90,11 +90,11 @@ If CLASS is actually an object, then also display current values of that object. " class") (let ((location (find-lisp-object-file-name class 'eieio-defclass))) (when location - (insert " in ‘") + (insert (substitute-command-keys " in ‘")) (help-insert-xref-button (help-fns-short-filename location) 'eieio-class-def class location 'eieio-defclass) - (insert "’"))) + (insert (substitute-command-keys "’")))) (insert ".\n") ;; Parents (let ((pl (eieio-class-parents class)) @@ -103,10 +103,10 @@ If CLASS is actually an object, then also display current values of that object. (insert " Inherits from ") (while (setq cur (pop pl)) (setq cur (eieio--class-name cur)) - (insert "‘") + (insert (substitute-command-keys "‘")) (help-insert-xref-button (symbol-name cur) 'help-function cur) - (insert (if pl "’, " "’"))) + (insert (substitute-command-keys (if pl "’, " "’")))) (insert ".\n"))) ;; Children (let ((ch (eieio-class-children class)) @@ -114,10 +114,10 @@ If CLASS is actually an object, then also display current values of that object. (when ch (insert " Children ") (while (setq cur (pop ch)) - (insert "‘") + (insert (substitute-command-keys "‘")) (help-insert-xref-button (symbol-name cur) 'help-function cur) - (insert (if ch "’, " "’"))) + (insert (substitute-command-keys (if ch "’, " "’")))) (insert ".\n"))) ;; System documentation (let ((doc (documentation-property class 'variable-documentation))) @@ -130,9 +130,9 @@ If CLASS is actually an object, then also display current values of that object. (when generics (insert (propertize "Specialized Methods:\n\n" 'face 'bold)) (dolist (generic generics) - (insert "‘") + (insert (substitute-command-keys "‘")) (help-insert-xref-button (symbol-name generic) 'help-function generic) - (insert "’") + (insert (substitute-command-keys "’")) (pcase-dolist (`(,qualifiers ,args ,doc) (eieio-method-documentation generic class)) (insert (format " %s%S\n" qualifiers args) @@ -245,11 +245,11 @@ are not abstract." (setq location (find-lisp-object-file-name ctr def))) (when location - (insert " in ‘") + (insert (substitute-command-keys " in ‘")) (help-insert-xref-button (help-fns-short-filename location) 'eieio-class-def ctr location 'eieio-defclass) - (insert "’")) + (insert (substitute-command-keys "’"))) (insert ".\nCreates an object of class " (symbol-name ctr) ".") (goto-char (point-max)) (if (autoloadp def) diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index ab01a109b7a..72a23cfdfc6 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -403,8 +403,8 @@ ;; Words inside \\[] tend to be for `substitute-command-keys'. ("\\\\\\\\\\[\\(\\(?:\\sw\\|\\s_\\)+\\)\\]" (1 font-lock-constant-face prepend)) - ;; Words inside ‘’ and `' tend to be symbol names. - ("[`‘]\\(\\(?:\\sw\\|\\s_\\)\\(?:\\sw\\|\\s_\\)+\\)['’]" + ;; Words inside ‘’ and '' and `' tend to be symbol names. + ("['`‘]\\(\\(?:\\sw\\|\\s_\\)\\(?:\\sw\\|\\s_\\)+\\)['’]" (1 font-lock-constant-face prepend)) ;; Constant values. ("\\_<:\\(?:\\sw\\|\\s_\\)+\\_>" 0 font-lock-builtin-face) @@ -452,8 +452,8 @@ ;; Erroneous structures. (,(concat "(" cl-errs-re "\\_>") (1 font-lock-warning-face)) - ;; Words inside ‘’ and `' tend to be symbol names. - ("[`‘]\\(\\(?:\\sw\\|\\s_\\)\\(?:\\sw\\|\\s_\\)+\\)['’]" + ;; Words inside ‘’ and '' and `' tend to be symbol names. + ("['`‘]\\(\\(?:\\sw\\|\\s_\\)\\(?:\\sw\\|\\s_\\)+\\)['’]" (1 font-lock-constant-face prepend)) ;; Constant values. ("\\_<:\\(?:\\sw\\|\\s_\\)+\\_>" 0 font-lock-builtin-face) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 074d3e8dda3..62900e08360 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2173,17 +2173,18 @@ will be deleted." "Installed" (capitalize status)) ;FIXME: Why comment-face? 'font-lock-face 'font-lock-comment-face)) - (insert " in ‘") + (insert (substitute-command-keys " in ‘")) ;; Todo: Add button for uninstalling. (help-insert-xref-button (abbreviate-file-name (file-name-as-directory pkg-dir)) 'help-package-def pkg-dir) (if (and (package-built-in-p name) (not (package-built-in-p name version))) - (insert "’,\n shadowing a " + (insert (substitute-command-keys + "’,\n shadowing a ") (propertize "built-in package" 'font-lock-face 'font-lock-builtin-face)) - (insert "’")) + (insert (substitute-command-keys "’"))) (if signed (insert ".") (insert " (unsigned).")) -- cgit v1.2.1