public inbox for howm-eng@lists.osdn.me
 help / color / mirror / Atom feed
* [Howm-eng 31] highlighting keywords, but not within a word
@ 2007-02-20 20:32 peter.mielke
  2007-02-21 12:33 ` [Howm-eng 32] " khi
  0 siblings, 1 reply; 2+ messages in thread
From: peter.mielke @ 2007-02-20 20:32 UTC (permalink / raw)


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-02-21 12:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-20 20:32 [Howm-eng 31] highlighting keywords, but not within a word peter.mielke
2007-02-21 12:33 ` [Howm-eng 32] " khi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).