argument @var{no-face} is non-@code{nil}, the function doesn't add
this face to the produced string.
+@defun substitute-quotes string
+This function works like @code{substitute-command-keys}, but only
+replaces quote characters.
+@end defun
+
@cindex advertised binding
If a command has multiple bindings, this function normally uses the
first one it finds. You can specify one particular key binding by
reaches the end of the script, Emacs will exit with an exit code from
the value of the final form.
++++
+** New function 'substitute-quotes'.
+This function works like 'substitute-command-keys' but only
+substitutes quote characters.
+
+++
** Emacs now supports setting 'user-emacs-directory' via '--init-directory'.
(when (class-abstract-p C)
(throw 'skip nil))
- (princ (substitute-command-keys "`"))
+ (princ (substitute-quotes "`"))
(princ name)
- (princ (substitute-command-keys "'"))
+ (princ (substitute-quotes "'"))
(when (slot-exists-p C 'key)
(when key
(princ " - Character Key: ")
(princ (substitute-command-keys " in `"))
(help-insert-xref-button (file-name-nondirectory fn)
'help-theme-def fn)
- (princ (substitute-command-keys "'")))
+ (princ (substitute-quotes "'")))
(princ ".\n")
(if (custom-theme-p theme)
(progn
(help-insert-xref-button
(help-fns-short-filename location)
'cl-type-definition type location 'define-type)
- (insert (substitute-command-keys "'")))
+ (insert (substitute-quotes "'")))
(insert ".\n")
;; Parents.
(insert " Inherits from ")
(while (setq cur (pop pl))
(setq cur (cl--class-name cur))
- (insert (substitute-command-keys "`"))
+ (insert (substitute-quotes "`"))
(help-insert-xref-button (symbol-name cur)
'cl-help-type cur)
(insert (substitute-command-keys (if pl "', " "'"))))
(when ch
(insert " Children ")
(while (setq cur (pop ch))
- (insert (substitute-command-keys "`"))
+ (insert (substitute-quotes "`"))
(help-insert-xref-button (symbol-name cur)
'cl-help-type cur)
(insert (substitute-command-keys (if ch "', " "'"))))
(when generics
(insert (propertize "Specialized Methods:\n\n" 'face 'bold))
(dolist (generic generics)
- (insert (substitute-command-keys "`"))
+ (insert (substitute-quotes "`"))
(help-insert-xref-button (symbol-name generic)
'help-function generic)
- (insert (substitute-command-keys "'"))
+ (insert (substitute-quotes "'"))
(pcase-dolist (`(,qualifiers ,args ,doc)
(cl--generic-method-documentation generic type))
(insert (format " %s%S\n" qualifiers args)
(help-insert-xref-button
(help-fns-short-filename location)
'cl-type-definition ctr location 'define-type)
- (insert (substitute-command-keys "'")))
+ (insert (substitute-quotes "'")))
(insert ".\nCreates an object of class " (symbol-name ctr) ".")
(goto-char (point-max))
(if (autoloadp def)
"',\n shadowing a ")
(propertize "built-in package"
'font-lock-face 'package-status-built-in))
- (insert (substitute-command-keys "'")))
+ (insert (substitute-quotes "'")))
(if signed
(insert ".")
(insert " (unsigned)."))
(get function
'derived-mode-parent))))
(when parent-mode
- (insert (substitute-command-keys " Parent mode: `"))
+ (insert (substitute-quotes " Parent mode: `"))
(let ((beg (point)))
(insert (format "%s" parent-mode))
(make-text-button beg (point)
'type 'help-function
'help-args (list parent-mode)))
- (insert (substitute-command-keys "'.\n")))))
+ (insert (substitute-quotes "'.\n")))))
(defun help-fns--obsolete (function)
;; Ignore lambda constructs, keyboard macros, etc.
(princ " This variable may be risky if used as a \
file-local variable.\n")
(when (assq variable safe-local-variable-values)
- (princ (substitute-command-keys
+ (princ (substitute-quotes
" However, you have added it to \
`safe-local-variable-values'.\n")))))
(insert-text-button
file 'type 'help-dir-local-var-def
'help-args (list variable file)))
- (princ (substitute-command-keys "'.\n"))))
- (princ (substitute-command-keys
+ (princ (substitute-quotes "'.\n"))))
+ (princ (substitute-quotes
" This variable's value is file-local.\n")))))))
(add-hook 'help-fns-describe-variable-functions #'help-fns--var-watchpoints)
((not permanent-local))
((bufferp locus)
(princ
- (substitute-command-keys
+ (substitute-quotes
" This variable's buffer-local value is permanent.\n")))
(t
- (princ (substitute-command-keys
+ (princ (substitute-quotes
" This variable's value is permanent \
if it is given a local binding.\n"))))))
(setq help-mode--current-data (list :symbol f))
(setq help-mode--current-data (list :symbol f
:file file-name))
- (princ (substitute-command-keys "Defined in `"))
+ (princ (substitute-quotes "Defined in `"))
(princ (help-fns-short-filename file-name))
- (princ (substitute-command-keys "'"))
+ (princ (substitute-quotes "'"))
;; Make a hyperlink to the library.
(save-excursion
(re-search-backward
(cond
((null this-keymap)
(insert "\nUses keymap "
- (substitute-command-keys "`")
+ (substitute-quotes "`")
(symbol-name name)
- (substitute-command-keys "'")
+ (substitute-quotes "'")
", which is not currently defined.\n")
(unless generate-summary
(setq keymap nil)))
(t (forward-char 1)))))
(buffer-string)))))
+(defun substitute-quotes (string)
+ "Substitute quote characters for display.
+Each grave accent \\=` is replaced by left quote, and each
+apostrophe \\=' is replaced by right quote. Left and right quote
+characters are specified by `text-quoting-style'."
+ (cond ((eq (text-quoting-style) 'curve)
+ (string-replace "`" "‘"
+ (string-replace "'" "’" string)))
+ ((eq (text-quoting-style) 'straight)
+ (string-replace "`" "'" string))
+ (t string)))
+
(defvar help--keymaps-seen nil)
(defun describe-map-tree (startmap &optional partial shadow prefix title
no-menu transl always-title mention-shadow
(dir (file-name-directory
(directory-file-name (file-name-directory file)))))
(replace-match "" nil nil nil 1)
- (insert (substitute-command-keys "`"))
+ (insert (substitute-quotes "`"))
;; Include the parent directory which may be regarded as
;; the category for the FN.
(help-insert-xref-button (file-relative-name file dir)
'octave-help-file fn)
- (insert (substitute-command-keys "'"))))
+ (insert (substitute-quotes "'"))))
;; Make 'See also' clickable.
(with-syntax-table octave-mode-syntax-table
(when (re-search-forward "^\\s-*See also:" nil t)
"\nUses keymap [`'‘]foobar-map['’], which is not currently defined.\n")))
(ert-deftest help-tests-substitute-command-keys/quotes ()
- (with-substitute-command-keys-test
+ (with-substitute-command-keys-test
+ (let ((text-quoting-style 'curve))
+ (test "quotes ‘like this’" "quotes ‘like this’")
+ (test "`x'" "‘x’")
+ (test "`" "‘")
+ (test "'" "’")
+ (test "\\`" "\\‘"))
+ (let ((text-quoting-style 'straight))
+ (test "quotes `like this'" "quotes 'like this'")
+ (test "`x'" "'x'")
+ (test "`" "'")
+ (test "'" "'")
+ (test "\\`" "\\'"))
+ (let ((text-quoting-style 'grave))
+ (test "quotes `like this'" "quotes `like this'")
+ (test "`x'" "`x'")
+ (test "`" "`")
+ (test "'" "'")
+ (test "\\`" "\\`"))))
+
+(ert-deftest help-tests-substitute-quotes ()
(let ((text-quoting-style 'curve))
- (test "quotes ‘like this’" "quotes ‘like this’")
- (test "`x'" "‘x’")
- (test "`" "‘")
- (test "'" "’")
- (test "\\`" "\\‘"))
+ (should (string= (substitute-quotes "quotes ‘like this’") "quotes ‘like this’"))
+ (should (string= (substitute-quotes "`x'") "‘x’"))
+ (should (string= (substitute-quotes "`") "‘"))
+ (should (string= (substitute-quotes "'") "’"))
+ (should (string= (substitute-quotes "\\`") "\\‘")))
(let ((text-quoting-style 'straight))
- (test "quotes `like this'" "quotes 'like this'")
- (test "`x'" "'x'")
- (test "`" "'")
- (test "'" "'")
- (test "\\`" "\\'"))
+ (should (string= (substitute-quotes "quotes `like this'") "quotes 'like this'"))
+ (should (string= (substitute-quotes "`x'") "'x'"))
+ (should (string= (substitute-quotes "`") "'"))
+ (should (string= (substitute-quotes "'") "'"))
+ (should (string= (substitute-quotes "\\`") "\\'")))
(let ((text-quoting-style 'grave))
- (test "quotes `like this'" "quotes `like this'")
- (test "`x'" "`x'")
- (test "`" "`")
- (test "'" "'")
- (test "\\`" "\\`"))))
+ (should (string= (substitute-quotes "quotes `like this'") "quotes `like this'"))
+ (should (string= (substitute-quotes "`x'") "`x'"))
+ (should (string= (substitute-quotes "`") "`"))
+ (should (string= (substitute-quotes "'") "'"))
+ (should (string= (substitute-quotes "\\`") "\\`"))))
(ert-deftest help-tests-substitute-command-keys/literals ()
(with-substitute-command-keys-test