emacs-devel
[Top][All Lists]
Advanced

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

Re: Exposing Isearch toggleable options


From: Oleh Krehel
Subject: Re: Exposing Isearch toggleable options
Date: Thu, 29 Oct 2015 11:49:10 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

"John Wiegley" <address@hidden> writes:

> For new users, I'm not sure whether it should be on by default or not. It's
> handy, for sure, but distracting maybe? I can't say without that mindset. I'd
> love to hear from some users to see what they think.

It's pretty distracting, and I'd be upset if I was still using `isearch'
(instead of `swiper').

Here's a solution using `hydra' that might work better:

(defhydra hydra-isearch-toggles (:exit t
                                 :columns 4
                                 :pre (isearch-update))
  "Toggles"
  ("w" isearch-toggle-word
       (format
        "word: %S"
        (eq isearch-regexp-function
            #'word-search-regexp)))
  ("_" isearch-toggle-symbol
       (format
        "symbol: %S"
        (eq isearch-regexp-function
            #'isearch-symbol-regexp)))
  ("'" isearch-toggle-character-fold
       (format
        "character-fold: %S"
        (eq isearch-regexp-function
            #'character-fold-to-regexp)))
  ("r" isearch-toggle-regexp
       (format
        "regexp: %S" isearch-regexp))
  ("SPC" isearch-toggle-lax-whitespace
         (format
          "lax-whitespace: %S"
          (if isearch-regexp
              isearch-regexp-lax-whitespace
            isearch-lax-whitespace)))
  ("c" isearch-toggle-case-fold
       (format
        "case-fold: %S"
        isearch-case-fold-search))
  ("i" isearch-toggle-invisible
       (format
        "invisible: %S"
        isearch-invisible))
  ("q" nil "quit")
  ("C-o" nil "quit"))
(define-key isearch-mode-map (kbd "C-o")
  'hydra-isearch-toggles/body)

Nothing extra is shown initially, but once you press "C-o" (I selected a
prefix different from "M-s", so that it's easy to compare), all
available options will be seen.

You can toggle options like this: "C-o c" "C-o _" etc.

If you set `:exit nil`, you can toggle many options at once: "C-o c_rq",
but you'll have to press "q" in the end to get rid of the menu.

As a small note, I've noticed an annoying delay after each toggle before
the minibuffer comes back to normal, as if there's a (sit-for 1)
somewhere. As long as the isearch input is modified, the user may think
that it's not yet ready for further input, and wait until isearch input
is un-modified again.

Here's a suggestion to fix it:

(defun isearch--momentary-message (string)
  "Print STRING at the end of the isearch prompt for 1 second"
  (lv-message string)
  (run-at-time 2.0 nil #'lv-delete-window))

This suggestion isn't without its faults though: it uses an extra line
and temporarily resizes windows to make space for the message.

Oleh








reply via email to

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