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: Sun, 29 Jun 2008 19:19:05 +0300 Organization: JURTA Message-ID: <871w2gi58m.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> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1214756904 23485 80.91.229.12 (29 Jun 2008 16:28:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 29 Jun 2008 16:28:24 +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 Sun Jun 29 18:29:09 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 1KCzm1-0005TY-0W for ged-emacs-devel@m.gmane.org; Sun, 29 Jun 2008 18:29:09 +0200 Original-Received: from localhost ([127.0.0.1]:59062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KCzlA-0005Yl-O0 for ged-emacs-devel@m.gmane.org; Sun, 29 Jun 2008 12:28:16 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KCzl5-0005X5-De for emacs-devel@gnu.org; Sun, 29 Jun 2008 12:28:11 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KCzl4-0005WL-L3 for emacs-devel@gnu.org; Sun, 29 Jun 2008 12:28:10 -0400 Original-Received: from [199.232.76.173] (port=48384 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KCzl4-0005WI-EG for emacs-devel@gnu.org; Sun, 29 Jun 2008 12:28:10 -0400 Original-Received: from anti-4.kiev.sovam.com ([62.64.120.202]:65292) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KCzl3-00035X-WE for emacs-devel@gnu.org; Sun, 29 Jun 2008 12:28:10 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by anti-4.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1KCzl1-0001Qt-69; Sun, 29 Jun 2008 19:28:07 +0300 In-Reply-To: (Stefan Monnier's message of "Sat, 28 Jun 2008 18:23:59 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-Scanner-Signature: 5705bde2e570895834f5a69800e19fe2 X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Trusted X-SpamTest-Info: Profiles 4143 [June 29 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:100139 Archived-At: >> Below is a patch that unifies two similar regexp-reading functions >> `keep-lines-read-args' and `occur-read-primary-args' into the general >> function `read-regexp'. It reads a regexp using the regexp history >> and provides some useful defaults. Like `keep-lines-read-args' >> it accepts the prompt as its argument, but without the trailing colon >> to be able to add the default value in parentheses. > > Sounds good. Installed. Now here is a patch for hi-lock.el that uses `read-regexp'. It also marks `hi-lock-regexp-history' as an obsolete variable that is replaced with `regexp-history'. Another change is renaming `hi-lock-face-history' to `hi-lock-face-defaults' and putting the face list to the minibuffer's default list instead of the history list: Index: lisp/hi-lock.el =================================================================== RCS file: /sources/emacs/emacs/lisp/hi-lock.el,v retrieving revision 1.51 diff -c -r1.51 hi-lock.el *** lisp/hi-lock.el 6 May 2008 07:57:38 -0000 1.51 --- lisp/hi-lock.el 29 Jun 2008 16:11:16 -0000 *************** *** 206,220 **** (defvar hi-lock-interactive-patterns nil "Patterns provided to hi-lock by user. Should not be changed.") ! (defvar hi-lock-face-history ! (list "hi-yellow" "hi-pink" "hi-green" "hi-blue" "hi-black-b" ! "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb") ! "History list of faces for hi-lock interactive functions.") ! ! ;(dolist (f hi-lock-face-history) (unless (facep f) (error "%s not a face" f))) ! ! (defvar hi-lock-regexp-history nil ! "History of regexps used for interactive fontification.") (defvar hi-lock-file-patterns-prefix "Hi-lock" "Search target for finding hi-lock patterns at top of file.") --- 206,221 ---- (defvar hi-lock-interactive-patterns nil "Patterns provided to hi-lock by user. Should not be changed.") ! (defvar hi-lock-face-defaults ! '("hi-yellow" "hi-pink" "hi-green" "hi-blue" "hi-black-b" ! "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb") ! "Default faces for hi-lock interactive functions.") ! ! ;(dolist (f hi-lock-face-defaults) (unless (facep f) (error "%s not a face" f))) ! ! (define-obsolete-variable-alias 'hi-lock-regexp-history ! 'regexp-history ! "23.1") (defvar hi-lock-file-patterns-prefix "Hi-lock" "Search target for finding hi-lock patterns at top of file.") *************** *** 232,239 **** (make-variable-buffer-local 'hi-lock-interactive-patterns) (put 'hi-lock-interactive-patterns 'permanent-local t) - (make-variable-buffer-local 'hi-lock-regexp-history) - (put 'hi-lock-regexp-history 'permanent-local t) (make-variable-buffer-local 'hi-lock-file-patterns) (put 'hi-lock-file-patterns 'permanent-local t) --- 233,238 ---- *************** *** 390,403 **** Interactively, prompt for REGEXP then FACE. Buffer-local history list maintained for regexps, global history maintained for faces. ! \\Use \\[next-history-element] and \\[previous-history-element] to retrieve next or previous history item. \(See info node `Minibuffer History'.)" (interactive (list ! (hi-lock-regexp-okay ! (read-from-minibuffer "Regexp to highlight line: " ! (cons (or (car hi-lock-regexp-history) "") 1 ) ! nil nil 'hi-lock-regexp-history)) (hi-lock-read-face-name))) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) --- 389,400 ---- Interactively, prompt for REGEXP then FACE. Buffer-local history list maintained for regexps, global history maintained for faces. ! \\Use \\[previous-history-element] to retrieve previous history items, ! and \\[next-history-element] to retrieve default values. \(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)) *************** *** 415,428 **** Interactively, prompt for REGEXP then FACE. Buffer-local history list maintained for regexps, global history maintained for faces. ! \\Use \\[next-history-element] and \\[previous-history-element] to retrieve next or previous history item. \(See info node `Minibuffer History'.)" (interactive (list ! (hi-lock-regexp-okay ! (read-from-minibuffer "Regexp to highlight: " ! (cons (or (car hi-lock-regexp-history) "") 1 ) ! nil nil 'hi-lock-regexp-history)) (hi-lock-read-face-name))) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) --- 412,423 ---- Interactively, prompt for REGEXP then FACE. Buffer-local history list maintained for regexps, global history maintained for faces. ! \\Use \\[previous-history-element] to retrieve previous history items, ! and \\[next-history-element] to retrieve default values. \(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)) *************** *** 440,448 **** (list (hi-lock-regexp-okay (hi-lock-process-phrase ! (read-from-minibuffer "Phrase to highlight: " ! (cons (or (car hi-lock-regexp-history) "") 1 ) ! nil nil 'hi-lock-regexp-history))) (hi-lock-read-face-name))) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) --- 435,441 ---- (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)) *************** *** 457,463 **** Interactively, prompt for REGEXP. Buffer-local history of inserted regexp's maintained. Will accept only regexps inserted by hi-lock interactive functions. \(See `hi-lock-interactive-patterns'.\) ! \\Use \\[minibuffer-complete] to complete a partially typed regexp. \(See info node `Minibuffer History'.\)" (interactive (if (and (display-popup-menus-p) (not last-nonmenu-event)) --- 450,457 ---- Interactively, prompt for REGEXP. Buffer-local history of inserted regexp's maintained. Will accept only regexps inserted by hi-lock interactive functions. \(See `hi-lock-interactive-patterns'.\) ! \\Use \\[previous-history-element] to retrieve previous history items, ! and \\[next-history-element] to retrieve default values. \(See info node `Minibuffer History'.\)" (interactive (if (and (display-popup-menus-p) (not last-nonmenu-event)) *************** *** 552,567 **** (intern (completing-read "Highlight using face: " obarray 'facep t ! (cons (car hi-lock-face-history) (let ((prefix (try-completion ! (substring (car hi-lock-face-history) 0 1) (mapcar (lambda (f) (cons f f)) ! hi-lock-face-history)))) (if (and (stringp prefix) ! (not (equal prefix (car hi-lock-face-history)))) (length prefix) 0))) ! '(hi-lock-face-history . 0)))) (defun hi-lock-set-pattern (regexp face) "Highlight REGEXP with face FACE." --- 546,561 ---- (intern (completing-read "Highlight using face: " obarray 'facep t ! (cons (car hi-lock-face-defaults) (let ((prefix (try-completion ! (substring (car hi-lock-face-defaults) 0 1) (mapcar (lambda (f) (cons f f)) ! hi-lock-face-defaults)))) (if (and (stringp prefix) ! (not (equal prefix (car hi-lock-face-defaults)))) (length prefix) 0))) ! nil (cdr hi-lock-face-defaults)))) (defun hi-lock-set-pattern (regexp face) "Highlight REGEXP with face FACE." -- Juri Linkov http://www.jurta.org/emacs/