emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 16dc1d597b 3/3: Char-fold quotation characters in *info* and *Hel


From: Lars Ingebrigtsen
Subject: master 16dc1d597b 3/3: Char-fold quotation characters in *info* and *Help*
Date: Fri, 6 May 2022 07:28:34 -0400 (EDT)

branch: master
commit 16dc1d597b70524782da58677a88135d20c1a617
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Char-fold quotation characters in *info* and *Help*
    
    * lisp/info.el (Info-mode):
    * lisp/help-mode.el (help-mode): Use it.
    * lisp/isearch.el (isearch-fold-quotes-mode): New minor mode
    (bug#24510).
---
 etc/NEWS          | 13 +++++++++++++
 lisp/help-mode.el |  3 ++-
 lisp/info.el      |  3 ++-
 lisp/isearch.el   | 17 +++++++++++++++++
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index fa7e2c4dcc..f7dddd36de 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 94bd591131..38a2f93a3c 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 abfb77b055..0bdb2f2e7a 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 8397bb95c6..b404efd42a 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]