From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleh Krehel Newsgroups: gmane.emacs.devel Subject: Re: Exposing Isearch toggleable options Date: Thu, 29 Oct 2015 11:49:10 +0100 Message-ID: <87wpu66jbt.fsf@gmail.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1446115739 24803 80.91.229.3 (29 Oct 2015 10:48:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Oct 2015 10:48:59 +0000 (UTC) Cc: emacs-devel To: Artur Malabarba Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 29 11:48:55 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZrklI-0004fK-N1 for ged-emacs-devel@m.gmane.org; Thu, 29 Oct 2015 11:48:52 +0100 Original-Received: from localhost ([::1]:43295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrklI-0001Tw-4C for ged-emacs-devel@m.gmane.org; Thu, 29 Oct 2015 06:48:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrklE-0001Td-0C for emacs-devel@gnu.org; Thu, 29 Oct 2015 06:48:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zrkl9-0002Gi-1Z for emacs-devel@gnu.org; Thu, 29 Oct 2015 06:48:47 -0400 Original-Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]:37011) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zrkl8-0002GY-RS for emacs-devel@gnu.org; Thu, 29 Oct 2015 06:48:42 -0400 Original-Received: by wicfv8 with SMTP id fv8so38954117wic.0 for ; Thu, 29 Oct 2015 03:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=LZ6y/SpHJCXSFiTMkgBTlGsnOX6A5zfUxR96m2z0XfU=; b=aqFAgTePXmzLX3GhtSpwAdjMr5BMVW4DGnOJNS8DwfRlTe06JJpPBDfzhpUQb8Zx17 6/e95IDfQrwlxy2X5BCR0dqleK8D9/YSKshRVCoxlqfoDXM5gMaVnIlOEbSNU/YEvZZq mJ7xIPpr0NHMYz8FBKVUlZr8y1ubI2LTa3MdXBj6xeSnmBhO7XOCSUqrKWUJVMqS7Pyf Y5BYy4pKwdUJC1+DsJ+Ljf4CavMy/1basS5uNiT3sEoI0Hzq7uyzLZWemlTqEz7jEYhB WabtGVRA8CdxKvfSl9PKWMFzfXMlyasB59krJDxTMYPcI38hkjDT1M5F30AkxGCutlPx Pq7w== X-Received: by 10.194.184.207 with SMTP id ew15mr1248687wjc.99.1446115722327; Thu, 29 Oct 2015 03:48:42 -0700 (PDT) Original-Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45]) by smtp.gmail.com with ESMTPSA id h4sm1115772wjx.41.2015.10.29.03.48.41 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 29 Oct 2015 03:48:41 -0700 (PDT) In-Reply-To: (John Wiegley's message of "Wed, 28 Oct 2015 22:53:27 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::234 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:192871 Archived-At: "John Wiegley" 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