=== modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-10-10 20:23:49 +0000 +++ lisp/ChangeLog 2012-10-10 22:01:18 +0000 @@ -1,5 +1,11 @@ 2012-10-10 Jambunathan K + * hi-lock.el (hi-lock-auto-select-face): New user variable. + (hi-lock-auto-select-face-defaults): New buffer local variable. + (hi-lock-read-face-name): Honor `hi-lock-auto-select-face'. + +2012-10-10 Jambunathan K + * hi-lock.el (hi-yellow, hi-pink, hi-green, hi-blue, hi-black-b) (hi-blue-b, hi-green-b, hi-red-b, hi-black-hb): Mark these faces as obsolete. === modified file 'lisp/hi-lock.el' --- lisp/hi-lock.el 2012-10-10 20:23:49 +0000 +++ lisp/hi-lock.el 2012-10-10 22:01:18 +0000 @@ -135,6 +135,14 @@ ;; It can have a function value. (put 'hi-lock-file-patterns-policy 'risky-local-variable t) +(defcustom hi-lock-auto-select-face nil + "Non-nil if highlighting commands should not prompt for face names. +When non-nil, each hi-lock command will cycle through faces in +`hi-lock-face-defaults'." + :type 'boolean + :group 'hi-lock + :version "24.3") + (defgroup hi-lock-faces nil "Faces for hi-lock." :group 'hi-lock @@ -221,8 +229,15 @@ "hi-lock-6" "hi-lock-7" "hi-lock-8" "hi-lock-9") "Default faces for hi-lock interactive functions.") -;;(dolist (f hi-lock-face-defaults) -;; (unless (facep f) (error "%s not a face" f))) +(defvar hi-lock-auto-select-face-defaults + (let ((l (copy-sequence hi-lock-face-defaults))) + (setcdr (last l) l)) + "Circular list of faces used for interactive highlighting. +When `hi-lock-auto-select-face' is non-nil, use the face at the +head of this list for next interactive highlighting. See also +`hi-lock-read-face-name'.") + +(make-variable-buffer-local 'hi-lock-auto-select-face-defaults) (define-obsolete-variable-alias 'hi-lock-regexp-history 'regexp-history @@ -577,20 +592,28 @@ regexp)) (defun hi-lock-read-face-name () - "Read face name from minibuffer with completion and history." - (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) - hi-lock-face-defaults))) - (if (and (stringp prefix) - (not (equal prefix (car hi-lock-face-defaults)))) - (length prefix) 0))) - 'face-name-history - (cdr hi-lock-face-defaults)))) + "Return face name for interactive highlighting. +When `hi-lock-auto-select-face' is non-nil, return head of +`hi-lock-auto-select-face-defaults'. Otherwise, read face name +from minibuffer with completion and history." + (if hi-lock-auto-select-face + ;; Return current head and rotate the face list. + (prog1 (car hi-lock-auto-select-face-defaults) + (setq hi-lock-auto-select-face-defaults + (cdr hi-lock-auto-select-face-defaults))) + (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) + hi-lock-face-defaults))) + (if (and (stringp prefix) + (not (equal prefix (car hi-lock-face-defaults)))) + (length prefix) 0))) + 'face-name-history + (cdr hi-lock-face-defaults))))) (defun hi-lock-set-pattern (regexp face) "Highlight REGEXP with face FACE."