From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Yanking isearch to highlight-regexp Date: Mon, 30 Jun 2008 22:59:14 +0300 Organization: JURTA Message-ID: <87bq1ihey5.fsf@jurta.org> References: <4853F884.7000609@gmail.com> <7dbe73ed0806141442h342f8ff0u83863f3980a7e229@mail.gmail.com> <48545D78.8080103@gmail.com> <4854E536.8040407@gmail.com> <87k5gql900.fsf@jurta.org> <878wwp1an8.fsf@jurta.org> <871w2gi58m.fsf@jurta.org> <87d4m0c9md.fsf@jurta.org> <87wsk89byj.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1214856135 9941 80.91.229.12 (30 Jun 2008 20:02:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 30 Jun 2008 20:02:15 +0000 (UTC) Cc: David Koppelman , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 30 22:03:00 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KDPaO-0002f1-Bl for ged-emacs-devel@m.gmane.org; Mon, 30 Jun 2008 22:02:52 +0200 Original-Received: from localhost ([127.0.0.1]:45216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KDPZX-00011d-UG for ged-emacs-devel@m.gmane.org; Mon, 30 Jun 2008 16:01:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KDPZS-00011U-UW for emacs-devel@gnu.org; Mon, 30 Jun 2008 16:01:55 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KDPZP-0000zm-9S for emacs-devel@gnu.org; Mon, 30 Jun 2008 16:01:53 -0400 Original-Received: from [199.232.76.173] (port=50927 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KDPZO-0000zh-U8 for emacs-devel@gnu.org; Mon, 30 Jun 2008 16:01:50 -0400 Original-Received: from relay03.kiev.sovam.com ([62.64.120.201]:54905) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KDPZO-0005RL-7z for emacs-devel@gnu.org; Mon, 30 Jun 2008 16:01:50 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay03.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1KDPZL-0002tQ-3U; Mon, 30 Jun 2008 23:01:47 +0300 In-Reply-To: (Stefan Monnier's message of "Sun, 29 Jun 2008 21:01:14 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-Scanner-Signature: c03b1e29655d4637f5ce20c285c706cd X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Trusted X-SpamTest-Info: Profiles 4154 [June 30 2008] X-SpamTest-Info: {received from trusted relay: common white list} X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: white ip list X-SpamTest-Rate: 10 X-SpamTest-Status: Trusted X-SpamTest-Status-Extended: trusted X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0278], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 6.x (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:100240 Archived-At: >> The following patch creates a new variable `face-name-history' and >> adds it to face-reading commands (most important is `read-face-name' >> that is used by many other commands). > > OK. Done. >> *************** >> *** 1227,1233 **** >> this regular expression. When called interactively with a prefix >> arg, prompt for a regular expression." >> (interactive (list (and current-prefix-arg >> ! (read-string "List faces matching regexp: ")))) >> (let ((all-faces (zerop (length regexp))) >> (frame (selected-frame)) >> (max-length 0) >> --- 1235,1241 ---- >> this regular expression. When called interactively with a prefix >> arg, prompt for a regular expression." >> (interactive (list (and current-prefix-arg >> ! (read-regexp "List faces matching regexp")))) >> (let ((all-faces (zerop (length regexp))) >> (frame (selected-frame)) >> (max-length 0) > > This is part of the other patch, isn't it? Yes, this is not related to the face history, but an attempt to use `read-regexp' where it makes sense. I now noticed that `read-regexp' doesn't provide backward compatible behavior for `keep-lines' and other commands. It puts the last history element in parens as the default value. I don't know why users insist on this behavior for `occur' since the last history is easy available via M-p. But at least I propose to keep old and different behavior for `occur' vs `keep-lines' and friends. The patch below adds a new argument `default' to `read-regexp' that is displayed in parens, and in `occur-read-primary-args' sets it to `(car regexp-history)'. A slightly different case is hi-lock. It used to put the last regexp from the history as initial input. But since using initial input is deprecated, this patch also sets the new `default' arg to `(car regexp-history)' for hi-lock commands as well. Index: lisp/replace.el =================================================================== RCS file: /sources/emacs/emacs/lisp/replace.el,v retrieving revision 1.273 diff -c -r1.273 replace.el *** lisp/replace.el 29 Jun 2008 16:09:08 -0000 1.273 --- lisp/replace.el 30 Jun 2008 19:54:43 -0000 *************** *** 522,536 **** Maximum length of the history list is determined by the value of `history-length', which see.") ! (defun read-regexp (prompt) "Read regexp as a string using the regexp history and some useful defaults. ! Prompt for a regular expression with PROMPT in the minibuffer. ! Provide the last element of the regexp history as the basic default, ! and return it on typing RET. Additional defaults are the string ! at point, the last isearch regexp, the last isearch string, and the ! last replacement regexp. Return the regexp as a string." ! (let* ((default (car regexp-history)) ! (defaults (list (regexp-quote (or (funcall (or find-tag-default-function (get major-mode 'find-tag-default-function) --- 522,535 ---- Maximum length of the history list is determined by the value of `history-length', which see.") ! (defun read-regexp (prompt &optional default) "Read regexp as a string using the regexp history and some useful defaults. ! Prompt for a regular expression with PROMPT (without a colon and ! space) in the minibuffer. The optional string argument DEFAULT ! provides the basic default value, that is returned on typing RET. ! Additional defaults are the string at point, the last isearch regexp, ! the last isearch string, and the last replacement regexp." ! (let* ((defaults (list (regexp-quote (or (funcall (or find-tag-default-function (get major-mode 'find-tag-default-function) *************** *** 1022,1028 **** (nreverse result)))) (defun occur-read-primary-args () ! (list (read-regexp "List lines matching regexp") (when current-prefix-arg (prefix-numeric-value current-prefix-arg)))) --- 1021,1028 ---- (nreverse result)))) (defun occur-read-primary-args () ! (list (read-regexp "List lines matching regexp" ! (car regexp-history)) (when current-prefix-arg (prefix-numeric-value current-prefix-arg)))) Index: lisp/hi-lock.el =================================================================== RCS file: /sources/emacs/emacs/lisp/hi-lock.el,v retrieving revision 1.52 diff -c -r1.52 hi-lock.el *** lisp/hi-lock.el 30 Jun 2008 19:36:38 -0000 1.52 --- lisp/hi-lock.el 30 Jun 2008 19:57:29 -0000 *************** *** 398,404 **** \(See info node `Minibuffer History'.)" (interactive (list ! (hi-lock-regexp-okay (read-regexp "Regexp to highlight line")) (hi-lock-read-face-name))) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) --- 398,405 ---- \(See info node `Minibuffer History'.)" (interactive (list ! (hi-lock-regexp-okay ! (read-regexp "Regexp to highlight line" (car regexp-history))) (hi-lock-read-face-name))) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) *************** *** 421,427 **** \(See info node `Minibuffer History'.)" (interactive (list ! (hi-lock-regexp-okay (read-regexp "Regexp to highlight")) (hi-lock-read-face-name))) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) --- 422,429 ---- \(See info node `Minibuffer History'.)" (interactive (list ! (hi-lock-regexp-okay ! (read-regexp "Regexp to highlight" (car regexp-history))) (hi-lock-read-face-name))) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) *************** *** 439,445 **** (list (hi-lock-regexp-okay (hi-lock-process-phrase ! (read-regexp "Phrase to highlight"))) (hi-lock-read-face-name))) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) --- 441,447 ---- (list (hi-lock-regexp-okay (hi-lock-process-phrase ! (read-regexp "Phrase to highlight" (car regexp-history)))) (hi-lock-read-face-name))) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) -- Juri Linkov http://www.jurta.org/emacs/