comparison lisp/hi-lock.el @ 67208:af4b92018fde

* hi-lock.el (hi-lock-line-face-buffer, hi-lock-face-buffer) (hi-lock-face-phrase-buffer): Use hi-yellow face. (hi-lock-write-interactive-patterns): Use comment-region.
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 29 Nov 2005 22:28:59 +0000
parents 152403ad207b
children a75f6e2ee182
comparison
equal deleted inserted replaced
67207:118bc6fc5238 67208:af4b92018fde
329 (hi-lock-regexp-okay 329 (hi-lock-regexp-okay
330 (read-from-minibuffer "Regexp to highlight line: " 330 (read-from-minibuffer "Regexp to highlight line: "
331 (cons (or (car hi-lock-regexp-history) "") 1 ) 331 (cons (or (car hi-lock-regexp-history) "") 1 )
332 nil nil 'hi-lock-regexp-history)) 332 nil nil 'hi-lock-regexp-history))
333 (hi-lock-read-face-name))) 333 (hi-lock-read-face-name)))
334 (or (facep face) (setq face 'rwl-yellow)) 334 (or (facep face) (setq face 'hi-yellow))
335 (unless hi-lock-buffer-mode (hi-lock-buffer-mode 1)) 335 (unless hi-lock-buffer-mode (hi-lock-buffer-mode 1))
336 (hi-lock-set-pattern 336 (hi-lock-set-pattern
337 ;; The \\(?:...\\) grouping construct ensures that a leading ^, +, * or ? 337 ;; The \\(?:...\\) grouping construct ensures that a leading ^, +, * or ?
338 ;; or a trailing $ in REGEXP will be interpreted correctly. 338 ;; or a trailing $ in REGEXP will be interpreted correctly.
339 (concat "^.*\\(?:" regexp "\\).*$") face)) 339 (concat "^.*\\(?:" regexp "\\).*$") face))
354 (hi-lock-regexp-okay 354 (hi-lock-regexp-okay
355 (read-from-minibuffer "Regexp to highlight: " 355 (read-from-minibuffer "Regexp to highlight: "
356 (cons (or (car hi-lock-regexp-history) "") 1 ) 356 (cons (or (car hi-lock-regexp-history) "") 1 )
357 nil nil 'hi-lock-regexp-history)) 357 nil nil 'hi-lock-regexp-history))
358 (hi-lock-read-face-name))) 358 (hi-lock-read-face-name)))
359 (or (facep face) (setq face 'rwl-yellow)) 359 (or (facep face) (setq face 'hi-yellow))
360 (unless hi-lock-buffer-mode (hi-lock-buffer-mode 1)) 360 (unless hi-lock-buffer-mode (hi-lock-buffer-mode 1))
361 (hi-lock-set-pattern regexp face)) 361 (hi-lock-set-pattern regexp face))
362 362
363 ;;;###autoload 363 ;;;###autoload
364 (defalias 'highlight-phrase 'hi-lock-face-phrase-buffer) 364 (defalias 'highlight-phrase 'hi-lock-face-phrase-buffer)
374 (hi-lock-process-phrase 374 (hi-lock-process-phrase
375 (read-from-minibuffer "Phrase to highlight: " 375 (read-from-minibuffer "Phrase to highlight: "
376 (cons (or (car hi-lock-regexp-history) "") 1 ) 376 (cons (or (car hi-lock-regexp-history) "") 1 )
377 nil nil 'hi-lock-regexp-history))) 377 nil nil 'hi-lock-regexp-history)))
378 (hi-lock-read-face-name))) 378 (hi-lock-read-face-name)))
379 (or (facep face) (setq face 'rwl-yellow)) 379 (or (facep face) (setq face 'hi-yellow))
380 (unless hi-lock-buffer-mode (hi-lock-buffer-mode 1)) 380 (unless hi-lock-buffer-mode (hi-lock-buffer-mode 1))
381 (hi-lock-set-pattern regexp face)) 381 (hi-lock-set-pattern regexp face))
382 382
383 ;;;###autoload 383 ;;;###autoload
384 (defalias 'unhighlight-regexp 'hi-lock-unface-buffer) 384 (defalias 'unhighlight-regexp 'hi-lock-unface-buffer)
438 438
439 Interactively added patterns are those normally specified using 439 Interactively added patterns are those normally specified using
440 `highlight-regexp' and `highlight-lines-matching-regexp'; they can 440 `highlight-regexp' and `highlight-lines-matching-regexp'; they can
441 be found in variable `hi-lock-interactive-patterns'." 441 be found in variable `hi-lock-interactive-patterns'."
442 (interactive) 442 (interactive)
443 (let ((prefix (format "%s %s:" (or comment-start "") "Hi-lock"))) 443 (if (null hi-lock-interactive-patterns)
444 (when (> (+ (point) (length prefix)) hi-lock-file-patterns-range) 444 (error "There are no interactive patterns"))
445 (beep) 445 (let ((beg (point)))
446 (message
447 "Warning, inserted keywords not close enough to top of file."))
448 (mapcar 446 (mapcar
449 (lambda (pattern) 447 (lambda (pattern)
450 (insert (format "%s (%s) %s\n" 448 (insert (format "Hi-lock: (%s)\n" (prin1-to-string pattern))))
451 prefix (prin1-to-string pattern) (or comment-end "")))) 449 hi-lock-interactive-patterns)
452 hi-lock-interactive-patterns))) 450 (comment-region beg (point)))
453 451 (when (> (point) hi-lock-file-patterns-range)
452 (warn "Inserted keywords not close enough to top of file")))
454 453
455 ;; Implementation Functions 454 ;; Implementation Functions
456 455
457 (defun hi-lock-process-phrase (phrase) 456 (defun hi-lock-process-phrase (phrase)
458 "Convert regexp PHRASE to a regexp that matches phrases. 457 "Convert regexp PHRASE to a regexp that matches phrases.