branch: elpa/casual
commit 9c2916187a01f2853a75ef3a5ccad422319ccaae
Merge: 0513c39686 598770b8c5
Author: Charles Choi <[email protected]>
Commit: GitHub <[email protected]>

    Merge pull request #340 from kickingvegas/339-fix-i-search-toggle-behavior
    
    Fix I-Search Toggle Behavior in `casual-isearch-tmenu`
---
 Makefile                             |   5 +--
 docs/Makefile                        |  15 +++++++--
 docs/casual.info                     | Bin 143571 -> 143516 bytes
 docs/casual.org                      |   2 +-
 docs/casual.texi                     |  16 ++++-----
 docs/images/casual-isearch-tmenu.png | Bin 145411 -> 158657 bytes
 docs/isearch.org                     |  11 +++----
 lisp/casual-isearch.el               |  62 +++++++++++++++--------------------
 tests/test-casual-isearch.el         |   9 +++--
 9 files changed, 59 insertions(+), 61 deletions(-)

diff --git a/Makefile b/Makefile
index ff2d08e630..13662e254b 100644
--- a/Makefile
+++ b/Makefile
@@ -76,11 +76,12 @@ tests:
 bump-casual:
        sed -i 's/;; Version: $(VERSION)/;; Version: $(VERSION_BUMP)/' 
$(MAIN_EL)
 
+bump-casual-info: VERSION_BUMP:=$(shell python -m semver nextver $(VERSION) 
$(BUMP_LEVEL))
 bump-casual-info:
        sed -i 's/+MACRO: version $(VERSION)/+MACRO: version $(VERSION_BUMP)/' 
docs/casual.org
 
-bump: bump-casual bump-casual-info
-       git commit -m 'Bump version to $(VERSION_BUMP)' $(MAIN_EL) 
docs/casual.org
+bump: bump-casual
+       git commit -m 'Bump version to $(VERSION_BUMP)' $(MAIN_EL)
        git push
 
 checkout-development:
diff --git a/docs/Makefile b/docs/Makefile
index 94002fa55f..2e22414315 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -1,11 +1,22 @@
 ##
-# Copyright 2024 Charles Y. Choi
+# Copyright 2024-2025 Charles Y. Choi
 #
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 TIMESTAMP := $(shell /bin/date "+%Y%m%d_%H%M%S")
 PKG_NAME=casual
 
-
 $(PKG_NAME).info: $(PKG_NAME).texi
        texi2any $<
 
diff --git a/docs/casual.info b/docs/casual.info
index 4797f91e00..3c1c7a87a4 100644
Binary files a/docs/casual.info and b/docs/casual.info differ
diff --git a/docs/casual.org b/docs/casual.org
index ce06bf75ce..adff08947f 100644
--- a/docs/casual.org
+++ b/docs/casual.org
@@ -5,7 +5,7 @@
 #+EMAIL: [email protected]
 #+OPTIONS: ':t toc:t author:t email:t H:4 f:t
 #+LANGUAGE: en
-#+MACRO: version 2.11.2-rc.1
+#+MACRO: version 2.11.2
 #+MACRO: kbd (eval (org-texinfo-kbd-macro $1))
 #+TEXINFO_FILENAME: casual.info
 #+TEXINFO_CLASS: casual
diff --git a/docs/casual.texi b/docs/casual.texi
index edfa7b0b90..77bc3a7c0a 100644
--- a/docs/casual.texi
+++ b/docs/casual.texi
@@ -20,7 +20,7 @@ Copyright © 2024-2025 Charles Y@. Choi
 @finalout
 @titlepage
 @title Casual User Guide
-@subtitle for version 2.11.0
+@subtitle for version 2.11.2
 @author Charles Y@. Choi (@email{kickingvegas@@gmail.com})
 @page
 @vskip 0pt plus 1filll
@@ -33,7 +33,7 @@ Copyright © 2024-2025 Charles Y@. Choi
 @node Top
 @top Casual User Guide
 
-Version: 2.11.0
+Version: 2.11.2
 
 Casual is a project to re-imagine the primary user interface for Emacs using 
keyboard-driven menus.
 
@@ -2984,7 +2984,7 @@ By enabling “@kbd{u} Use Unicode Symbols” from the 
Settings menu, Casual Inf
 @node I-Search
 @section I-Search
 
-@cindex ISearch
+@cindex isearch
 @cindex I-Search
 @vindex casual-isearch-tmenu
 
@@ -3002,14 +3002,12 @@ Casual I-Search is a user interface for Emacs 
Incremental Search (@ref{Increment
 
 @cindex I-Search Install
 
-The main menu for Casual I-Search is @code{casual-isearch-tmenu}. Bind this 
menu in the keymap @code{isearch-mode-map} as follows in your initialization 
file.
+The main menu for Casual I-Search is @code{casual-isearch-tmenu}. Bind this 
menu to @kbd{C-o} (or your binding of preference) in the keymap 
@code{isearch-mode-map} as follows in your initialization file.
 
 @lisp
 (keymap-set isearch-mode-map "C-o" #'casual-isearch-tmenu)
 @end lisp
 
-The keybinding to @code{casual-isearch-tmenu} can be changed to user 
preference.
-
 @node I-Search Usage
 @subsection I-Search Usage
 
@@ -3027,7 +3025,7 @@ Commands to edit the search string. The type/extent of 
the string (word, symbol,
 Invoke @code{query-replace} or @code{query-replace-regexp} on matched strings.
 
 @item Toggle
-Commands to configure the type of search.
+Commands to configure the type of search. Toggling any menu item in this 
section will dismiss the Transient menu and return you back to the I-Search 
minibuffer prompt.
 
 @item Misc
 Miscellaneous commands. From here the search string can be fed into 
@code{occur} or be highlighted.
@@ -3036,9 +3034,7 @@ Miscellaneous commands. From here the search string can 
be fed into @code{occur}
 Navigation commands for matched strings.
 @end table
 
-When in search mode (typically via the keybinding @kbd{C-s} or @kbd{C-r}), 
pressing the keybinding @kbd{C-o} (or binding of your preference) will raise 
the Transient menu @code{casual-isearch-tmenu}. Once raised, only the 
@emph{I-Search} commands in the @strong{Replace} and @strong{Misc} sections 
will automatically dismiss the menu when selected. All other @emph{I-Search} 
commands will @emph{not} dismiss the menu.
-
-Note that editing the search text via @code{isearch-edit-string} will enter a 
recursive editing mode that is normally exited when pressing the return 
(@code{RET}) key.
+When in search mode (typically via the keybinding @kbd{C-s} or @kbd{C-r}), 
pressing the keybinding @kbd{C-o} (or binding of your preference) will raise 
the Transient menu @code{casual-isearch-tmenu}. Once raised, only the 
@emph{I-Search} commands in the @strong{Toggle}, @strong{Replace}, and 
@strong{Misc} sections will automatically dismiss the menu when selected. All 
other @emph{I-Search} commands will @emph{not} dismiss the menu.
 
 Use @kbd{C-g} to dismiss this Transient menu.
 
diff --git a/docs/images/casual-isearch-tmenu.png 
b/docs/images/casual-isearch-tmenu.png
index d4fec3b301..a7edff4149 100644
Binary files a/docs/images/casual-isearch-tmenu.png and 
b/docs/images/casual-isearch-tmenu.png differ
diff --git a/docs/isearch.org b/docs/isearch.org
index 9cc2903486..d67fe87344 100644
--- a/docs/isearch.org
+++ b/docs/isearch.org
@@ -1,5 +1,5 @@
 * I-Search
-#+CINDEX: ISearch
+#+CINDEX: isearch
 #+CINDEX: I-Search
 #+VINDEX: casual-isearch-tmenu
 
@@ -13,13 +13,12 @@ Casual I-Search is a user interface for Emacs Incremental 
Search ([[info:emacs#I
 :END:
 #+CINDEX: I-Search Install
 
-The main menu for Casual I-Search is ~casual-isearch-tmenu~. Bind this menu in 
the keymap ~isearch-mode-map~ as follows in your initialization file.
+The main menu for Casual I-Search is ~casual-isearch-tmenu~. Bind this menu to 
{{{kbd(C-o)}}} (or your binding of preference) in the keymap ~isearch-mode-map~ 
as follows in your initialization file.
 
 #+begin_src elisp :lexical yes
   (keymap-set isearch-mode-map "C-o" #'casual-isearch-tmenu)
 #+end_src
 
-The keybinding to ~casual-isearch-tmenu~ can be changed to user preference.
 
 ** I-Search Usage
 #+CINDEX: I-Search Usage
@@ -32,14 +31,12 @@ The main menu for Casual I-Search is organized into the 
following sections:
 
 - Replace :: Invoke ~query-replace~ or ~query-replace-regexp~ on matched 
strings.
 
-- Toggle :: Commands to configure the type of search.
+- Toggle :: Commands to configure the type of search. Toggling any menu item 
in this section will dismiss the Transient menu and return you back to the 
I-Search minibuffer prompt.
 
 - Misc :: Miscellaneous commands. From here the search string can be fed into 
~occur~ or be highlighted.
 
 - Navigation :: Navigation commands for matched strings.
 
-When in search mode (typically via the keybinding {{{kbd(C-s)}}} or 
{{{kbd(C-r)}}}), pressing the keybinding {{{kbd(C-o)}}} (or binding of your 
preference) will raise the Transient menu ~casual-isearch-tmenu~. Once raised, 
only the /I-Search/ commands in the *Replace* and *Misc* sections will 
automatically dismiss the menu when selected. All other /I-Search/ commands 
will /not/ dismiss the menu.
-
-Note that editing the search text via ~isearch-edit-string~ will enter a 
recursive editing mode that is normally exited when pressing the return (~RET~) 
key.
+When in search mode (typically via the keybinding {{{kbd(C-s)}}} or 
{{{kbd(C-r)}}}), pressing the keybinding {{{kbd(C-o)}}} (or binding of your 
preference) will raise the Transient menu ~casual-isearch-tmenu~. Once raised, 
only the /I-Search/ commands in the *Toggle*, *Replace*, and *Misc* sections 
will automatically dismiss the menu when selected. All other /I-Search/ 
commands will /not/ dismiss the menu.
 
 Use {{{kbd(C-g)}}} to dismiss this Transient menu.
diff --git a/lisp/casual-isearch.el b/lisp/casual-isearch.el
index 2c51dbf947..ec1fcad063 100644
--- a/lisp/casual-isearch.el
+++ b/lisp/casual-isearch.el
@@ -35,38 +35,15 @@
 ;; (require 'casual-isearch) ; optional if using autoloaded menu
 ;; (keymap-set isearch-mode-map "C-o" #'casual-isearch-tmenu)
 
-;; If you are using Emacs ≤ 30.0, you will need to update the built-in package
-;; `transient'. By default, `package.el' will not upgrade a built-in package.
-;; Set the customizable variable `package-install-upgrade-built-in' to `t' to
-;; override this. For more details, please refer to the "Install" section on
-;; this project's repository web page.
-
 ;;; Code:
 (require 'casual-lib)
 (require 'casual-isearch-utils)
 (require 'casual-isearch-settings)
 
-(defun casual-isearch--toggle-regex-and-edit ()
-  "Invoke `isearch-toggle-regexp' then `isearch-edit-string'."
-  (interactive)
-  (isearch-toggle-regexp)
-  (isearch-edit-string))
-
-(defun casual-isearch--toggle-symbol-and-edit ()
-  "Invoke `isearch-toggle-symbol' then `isearch-edit-string'."
-  (interactive)
-  (isearch-toggle-symbol)
-  (isearch-edit-string))
-
-(defun casual-isearch--toggle-word-and-edit ()
-  "Invoke `isearch-toggle-word' then `isearch-edit-string'."
-  (interactive)
-  (isearch-toggle-symbol)
-  (isearch-edit-string))
-
 ;;;###autoload (autoload 'casual-isearch-tmenu "casual-isearch" nil t)
 (transient-define-prefix casual-isearch-tmenu ()
   "Transient menu for I-Search."
+  :refresh-suffixes t
   [["Edit Search String"
     ("e" "Edit the search string (recursive)" isearch-edit-string
      :transient t)
@@ -79,27 +56,40 @@
     ("t" "Pull thing from buffer" isearch-forward-thing-at-point)]
 
    ["Replace"
-    ("r" "Start ‘query-replace’" isearch-query-replace
-     :if-nil buffer-read-only)
-    ("x" "Start ‘query-replace-regexp’" isearch-query-replace-regexp
-     :if-nil buffer-read-only)]]
+    :if-nil buffer-read-only
+    ("r" "Start ‘query-replace’" isearch-query-replace)
+    ("x" "Start ‘query-replace-regexp’" isearch-query-replace-regexp)]]
 
   [["Toggle"
     ("X" "Regexp searching (edit)"
-     casual-isearch--toggle-regex-and-edit
-     :transient t)
+     isearch-toggle-regexp
+     :description (lambda () (casual-lib-checkbox-label isearch-regexp
+                                                   "Regexp search")))
+
     ("S" "Symbol searching (edit)"
-     casual-isearch--toggle-symbol-and-edit
-     :transient t)
+     isearch-toggle-symbol
+     :description (lambda () (casual-lib-checkbox-label
+                         (eq isearch-regexp-function #'isearch-symbol-regexp)
+                         "Symbol search")))
+
     ("W" "Word searching (edit)"
-     casual-isearch--toggle-word-and-edit
-     :transient t)
+     isearch-toggle-word
+     :description (lambda () (casual-lib-checkbox-label
+                         (eq isearch-regexp-function #'word-search-regexp)
+                         "Word search")))
+
     ("F" "Case fold"
      isearch-toggle-case-fold
-     :transient t)
+     :description (lambda () (casual-lib-checkbox-label
+                         isearch-case-fold-search
+                         "Case insensitive")))
     ("L" "Lax whitespace"
      isearch-toggle-lax-whitespace
-     :transient t)]
+     :description (lambda () (casual-lib-checkbox-label
+                         (if isearch-regexp
+                             isearch-regexp-lax-whitespace
+                           isearch-lax-whitespace)
+                         "Lax whitespace")))]
 
    ["Misc"
     ("o" "Occur" isearch-occur)
diff --git a/tests/test-casual-isearch.el b/tests/test-casual-isearch.el
index 238372f1b0..ff65027e29 100644
--- a/tests/test-casual-isearch.el
+++ b/tests/test-casual-isearch.el
@@ -41,6 +41,9 @@
               (casualt-mock #'isearch-forward-thing-at-point)
               (casualt-mock #'isearch-query-replace)
               (casualt-mock #'isearch-query-replace-regexp)
+              (casualt-mock #'isearch-toggle-regexp)
+              (casualt-mock #'isearch-toggle-symbol)
+              (casualt-mock #'isearch-toggle-word)
               (casualt-mock #'isearch-toggle-case-fold)
               (casualt-mock #'isearch-toggle-lax-whitespace)
               (casualt-mock #'isearch-occur)
@@ -60,9 +63,9 @@
                (:binding "r" :command isearch-query-replace)
                (:binding "x" :command isearch-query-replace-regexp)
 
-               (:binding "X" :command casual-isearch--toggle-regex-and-edit)
-               (:binding "S" :command casual-isearch--toggle-symbol-and-edit)
-               (:binding "W" :command casual-isearch--toggle-word-and-edit)
+               (:binding "X" :command isearch-toggle-regexp)
+               (:binding "S" :command isearch-toggle-symbol)
+               (:binding "W" :command isearch-toggle-word)
                (:binding "F" :command isearch-toggle-case-fold)
                (:binding "L" :command isearch-toggle-lax-whitespace)
                (:binding "o" :command isearch-occur)

Reply via email to