[Howm-eng 31] highlighting keywords, but not within a word

Zurück zum Archiv-Index

Peter Mielke peter****@gmail*****
Wed Feb 21 05:32:28 JST 2007


One irritation i had with the highlighing in howm buffers is that the
keywords were being highlighted even within a word. So for example i
have one keyword "ris" and the "ris" in "highrise" was being
highlighted. So i added word breaks to the regular expression for
highlighting keywords:

(defun howm-action-lock-setup ()
  (setq action-lock-case-fold-search howm-keyword-case-fold-search)
  (action-lock-mode t)
  (let* ((date-al (action-lock-date "{_}" howm-dtime-format)))
    ;; override the rule in action-lock.el
    (action-lock-add-rules (list date-al) t))

  ;; xxx begin changed code
  (let* ((ks
          (mapcar (lambda (x)
                    ;; add word break checks
                    (format "\\b%s\\b" x))
                  (mapcar 'regexp-quote (howm-keyword-for-goto))))
         (r (mapconcat 'identity ks "\\|"))
         ;; xxx end changed code

         (wiki (howm-action-lock-search howm-wiki-regexp
                                        howm-wiki-regexp-pos
                                        howm-wiki-regexp-hilit-pos
                                        t
                                        ))
         ;;          (explicit (howm-action-lock-goto howm-ref-regexp
         (explicit (howm-action-lock-search howm-ref-regexp
                                            howm-ref-regexp-pos
                                            howm-ref-regexp-hilit-pos
                                            ))
         (implicit (howm-action-lock-search r 0))
         (rev (howm-action-lock-related howm-keyword-regexp
                                        howm-keyword-regexp-pos
                                        howm-keyword-regexp-hilit-pos))
         (date (howm-action-lock-date-rule))
         (done (howm-action-lock-reminder-done-rule))
         (all `(
                ,explicit
                ,rev
                ,@(if ks (list implicit) nil)
                ,wiki
                ,@(if (howm-menu-p) nil (list date done))
                ))
         )
    ;; don't override the rule in action-lock.el
    ;; esp. http://xxx should call browser even if "<<< http" exists
    (action-lock-add-rules all)))

Hope this helps



More information about the Howm-eng mailing list
Zurück zum Archiv-Index