From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: David Koppelman <koppel@ece.lsu.edu>, emacs-devel@gnu.org
Subject: Re: Yanking isearch to highlight-regexp
Date: Sun, 29 Jun 2008 19:19:05 +0300 [thread overview]
Message-ID: <871w2gi58m.fsf@jurta.org> (raw)
In-Reply-To: <jwvtzfdi4kf.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 28 Jun 2008 18:23:59 -0400")
>> 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.
! \\<minibuffer-local-map>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.
! \\<minibuffer-local-map>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.
! \\<minibuffer-local-map>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.
! \\<minibuffer-local-map>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'.\)
! \\<minibuffer-local-must-match-map>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'.\)
! \\<minibuffer-local-map>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/
next prev parent reply other threads:[~2008-06-29 16:19 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-14 16:57 Yanking isearch to highlight-regexp Lennart Borgman (gmail)
2008-06-14 21:42 ` Mathias Dahl
2008-06-14 21:50 ` Stefan Monnier
2008-06-14 21:54 ` Mathias Dahl
2008-06-15 0:32 ` Juri Linkov
2008-06-15 0:08 ` Lennart Borgman (gmail)
2008-06-15 0:33 ` Juri Linkov
2008-06-15 1:48 ` Stefan Monnier
2008-06-15 9:47 ` Lennart Borgman (gmail)
2008-06-15 20:48 ` Juri Linkov
2008-06-15 21:10 ` Lennart Borgman (gmail)
2008-06-15 22:54 ` Juri Linkov
2008-06-15 23:09 ` Lennart Borgman (gmail)
2008-06-16 9:34 ` Juri Linkov
2008-06-16 11:13 ` Lennart Borgman
2008-06-16 21:48 ` Juri Linkov
2008-06-16 18:50 ` David Koppelman
2008-06-16 19:08 ` Lennart Borgman (gmail)
2008-06-16 21:50 ` Juri Linkov
2008-06-17 18:50 ` David Koppelman
2008-06-24 23:09 ` Juri Linkov
2008-06-25 1:43 ` Stefan Monnier
2008-06-25 20:32 ` Juri Linkov
2008-06-25 22:16 ` Miles Bader
2008-06-25 22:22 ` Lennart Borgman (gmail)
2008-06-25 22:58 ` Miles Bader
2008-06-27 23:15 ` Global keymaps [was: Yanking isearch to highlight-regexp] Juri Linkov
2008-06-27 23:20 ` Lennart Borgman (gmail)
2008-06-27 23:32 ` Juri Linkov
2008-06-28 0:28 ` Global keymaps Miles Bader
2008-06-28 1:25 ` Stefan Monnier
2008-06-28 19:45 ` Juri Linkov
2008-06-28 22:51 ` Stefan Monnier
2008-06-29 16:17 ` Juri Linkov
2008-06-29 18:03 ` Stefan Monnier
2008-06-29 19:28 ` Juri Linkov
2008-06-29 20:03 ` Stefan Monnier
2008-06-29 20:52 ` Juri Linkov
2008-06-29 21:24 ` Lennart Borgman (gmail)
2008-06-30 1:00 ` Stefan Monnier
2008-06-28 22:02 ` Yanking isearch to highlight-regexp Juri Linkov
2008-06-28 22:23 ` Stefan Monnier
2008-06-29 16:19 ` Juri Linkov [this message]
2008-06-29 18:07 ` Stefan Monnier
2008-06-29 19:29 ` Juri Linkov
2008-06-29 20:05 ` Stefan Monnier
2008-06-29 20:55 ` Juri Linkov
2008-06-30 1:01 ` Stefan Monnier
2008-06-30 19:59 ` Juri Linkov
2008-07-01 21:34 ` Grep key bindings (was: Yanking isearch to highlight-regexp) Juri Linkov
2008-07-01 21:44 ` Grep key bindings Miles Bader
2008-07-01 21:54 ` Juri Linkov
2008-07-01 22:11 ` Miles Bader
2008-07-02 22:42 ` Juri Linkov
2008-07-03 6:53 ` joakim
2008-07-03 7:07 ` Miles Bader
2008-07-03 13:18 ` Ted Zlatanov
2008-07-03 22:06 ` Stefan Monnier
2008-07-03 14:50 ` Dan Nicolaescu
2008-07-03 15:37 ` Phil Jackson
2008-07-03 16:59 ` Drew Adams
2008-07-04 10:46 ` Eli Zaretskii
2008-07-04 10:59 ` Miles Bader
2008-07-30 17:49 ` Yanking isearch to highlight-regexp Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871w2gi58m.fsf@jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
--cc=koppel@ece.lsu.edu \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.