=== modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-10-12 16:19:16 +0000 +++ lisp/ChangeLog 2012-10-12 18:03:45 +0000 @@ -1,5 +1,10 @@ 2012-10-12 Jambunathan K + * hi-lock.el (hi-lock-unface-buffer): With prefix arg, unhighlight + all hi-lock patterns in buffer. + +2012-10-12 Jambunathan K + * hi-lock.el (hi-lock-unface-buffer): Prompt user with useful defaults. Specifically, if cursor is on an highlighted text, offer a regexp that matches that text as the default. Update === modified file 'lisp/hi-lock.el' --- lisp/hi-lock.el 2012-10-12 16:19:16 +0000 +++ lisp/hi-lock.el 2012-10-12 17:35:34 +0000 @@ -491,17 +491,18 @@ updated as you type." ;;;###autoload (defalias 'unhighlight-regexp 'hi-lock-unface-buffer) ;;;###autoload -(defun hi-lock-unface-buffer (regexp) +(defun hi-lock-unface-buffer (regexp &optional prefix-arg) "Remove highlighting of each match to REGEXP set by hi-lock. -Interactively, prompt for REGEXP. If the cursor is on a -previously highlighted text and if the associated regexp can be -inferred via simple heuristics, offer that regexp as default. -Otherwise, prompt for REGEXP with completion and limit the -choices to only those regexps used previously with hi-lock -commands. +Interactively, when PREFIX-ARG is non-nil, unhighlight all +highlighted text in current buffer. When PREFIX-ARG is nil, +prompt for REGEXP. If the cursor is on a previously highlighted +text and if the associated regexp can be inferred via simple +heuristics, offer that regexp as default. Otherwise, prompt for +REGEXP with completion and limit the choices to only those +regexps used previously with hi-lock commands. -If this command is invoked via menu, make no attempt to infer -REGEXP from text at point." +If this command is invoked via menu, pop-up a list of currently +highlighted patterns." (interactive (if (and (display-popup-menus-p) (listp last-nonmenu-event) @@ -570,18 +571,22 @@ REGEXP from text at point." ;; a reasonable default. (caar candidate-hi-lock-patterns)))))) (list + (and (not current-prefix-arg) (completing-read "Regexp to unhighlight: " (or candidate-hi-lock-patterns hi-lock-interactive-patterns) - nil t default-regexp))))) - (let ((keyword (assoc regexp hi-lock-interactive-patterns))) + nil t default-regexp)) + current-prefix-arg)))) + (dolist (re (if (not prefix-arg) (list regexp) + (mapcar #'car hi-lock-interactive-patterns))) + (let ((keyword (assoc re hi-lock-interactive-patterns))) (when keyword (font-lock-remove-keywords nil (list keyword)) (setq hi-lock-interactive-patterns (delq keyword hi-lock-interactive-patterns)) (remove-overlays - nil nil 'hi-lock-overlay-regexp (hi-lock-string-serialize regexp)) - (when font-lock-fontified (font-lock-fontify-buffer))))) + nil nil 'hi-lock-overlay-regexp (hi-lock-string-serialize re)) + (when font-lock-fontified (font-lock-fontify-buffer)))))) ;;;###autoload (defun hi-lock-write-interactive-patterns ()