diff --git a/etc/NEWS b/etc/NEWS index fa7e2c4dcca..f7dddd36de1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -136,6 +136,13 @@ of 'user-emacs-directory'. * Incompatible changes in Emacs 29.1 +--- +** Isearch in *Help* and *info* now char-folds quote characters by default. +This means that you can say 'C-s `foo' (GRAVE ACCENT) if the buffer +contains "‘foo" (LEFT SINGLE QUOTATION MARK) and the like. These +quotation characters look somewhat similar in some fonts. To switch +this off, disable the new 'isearch-fold-quotes-mode' minor mode. + --- ** Sorting commands no longer necessarily change modification status. In earlier Emacs versions, commands like 'M-x sort-lines' would always @@ -1636,6 +1643,12 @@ functions. * Lisp Changes in Emacs 29.1 +--- +*** New minor mode 'isearch-fold-quotes-mode'. +This sets up 'search-default-mode' so that quote characters are +char-folded into each other. It is used, by default, in *Help* and +*info* buffers. + +++ ** New macro 'buffer-local-set-state'. This is a helper macro to be used by minor modes that wish to restore diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 94bd5911311..38a2f93a3c3 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -415,7 +415,8 @@ Commands: help-mode-tool-bar-map) (setq-local help-mode--current-data nil) (setq-local bookmark-make-record-function - #'help-bookmark-make-record)) + #'help-bookmark-make-record) + (isearch-fold-quotes-mode)) ;;;###autoload (defun help-mode-setup () diff --git a/lisp/info.el b/lisp/info.el index abfb77b0552..0bdb2f2e7a3 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -4490,7 +4490,8 @@ Advanced commands: (setq-local revert-buffer-function #'Info-revert-buffer-function) (setq-local font-lock-defaults '(Info-mode-font-lock-keywords t t)) (Info-set-mode-line) - (setq-local bookmark-make-record-function #'Info-bookmark-make-record)) + (setq-local bookmark-make-record-function #'Info-bookmark-make-record) + (isearch-fold-quotes-mode)) ;; When an Info buffer is killed, make sure the associated tags buffer ;; is killed too. diff --git a/lisp/isearch.el b/lisp/isearch.el index 8397bb95c6b..b404efd42a1 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -4466,6 +4466,23 @@ CASE-FOLD non-nil means the search was case-insensitive." (isearch-search) (isearch-update)) + + +(defvar isearch-fold-quotes-mode--state) +(define-minor-mode isearch-fold-quotes-mode + "Minor mode to aid searching for \\=` characters in help modes." + :lighter "" + (if isearch-fold-quotes-mode + (setq-local isearch-fold-quotes-mode--state + (buffer-local-set-state + search-default-mode + (lambda (string &optional _lax) + (thread-last + (regexp-quote string) + (replace-regexp-in-string "`" "[`‘]") + (replace-regexp-in-string "'" "['’]"))))) + (buffer-local-restore-state isearch-fold-quotes-mode--state))) + (provide 'isearch) ;;; isearch.el ends here