From: lawrence m. <we...@gm...> - 2003-08-12 21:09:52
|
erc-match-current-nick-p does this: | (string-match (concat "\\b" (erc-current-nick) "\\b") msg) Which fails for nicks ending in something not a word-constituent. In particular it fails when ERC appends its default "alternate nick" character: Hence, if we log in, and lawrence is already taken, we get the nick lawrence`. This will never be matched by the above bit of code, since ?\` is not a word constituent. Whats the best way of fixing this? Change the syntax table to make all valid IRC nick characters part of a word? Or just extend the regular expression manually. -- lawrence mitchell <we...@gm...> |
From: Alex S. <al...@em...> - 2003-08-12 23:03:07
|
lawrence mitchell <we...@gm...> writes: > Whats the best way of fixing this? Change the syntax table to > make all valid IRC nick characters part of a word? Or just > extend the regular expression manually. Fix the syntax table instead. erc-mode-syntax-table (erc.el) -- default syntax table, usually not interesting erc-button-syntax-table (erc-button.el) -- syntax table to use while buttonizing things, which was added to do exactly that: simplify the searching of nicks and similar stuff Alex. -- http://www.emacswiki.org/alex/ There is no substitute for experience. |
From: lawrence m. <we...@gm...> - 2003-08-13 14:06:53
|
Alex Schroeder wrote: [...] > erc-mode-syntax-table (erc.el) -- default syntax table, usually not > interesting > erc-button-syntax-table (erc-button.el) -- syntax table to use while > buttonizing things, which was added to do exactly that: simplify the > searching of nicks and similar stuff How about something like this: It uses a copy of erc-button-syntax-table, since people may not use erc-button. Should the variable go in erc.el instead, e.g. as erc-nick-word-syntax-table or somesuch? --8<---------------cut here---------------start------------->8--- Index: erc-match.el =================================================================== RCS file: /cvsroot/erc/erc/erc-match.el,v retrieving revision 1.21 diff -u -r1.21 erc-match.el --- erc-match.el 29 Jul 2003 17:20:27 -0000 1.21 +++ erc-match.el 13 Aug 2003 13:48:53 -0000 @@ -210,6 +210,29 @@ :group 'erc-match :type 'hook) +;; Internal variables: + +;; This is exactly the same as erc-button-syntax-table. Should we +;; just put it in erc.el +(defvar erc-match-syntax-table + (let ((table (make-syntax-table))) + (modify-syntax-entry ?\( "w" table) + (modify-syntax-entry ?\) "w" table) + (modify-syntax-entry ?\[ "w" table) + (modify-syntax-entry ?\] "w" table) + (modify-syntax-entry ?\{ "w" table) + (modify-syntax-entry ?\} "w" table) + (modify-syntax-entry ?` "w" table) + (modify-syntax-entry ?' "w" table) + (modify-syntax-entry ?^ "w" table) + (modify-syntax-entry ?- "w" table) + (modify-syntax-entry ?_ "w" table) + (modify-syntax-entry ?| "w" table) + table) + "Syntax table used when highlighting messages. +This syntax table should make all the legal nick characters word +constituents.") + ;; Faces: (defface erc-current-nick-face '((t (:bold t :foreground "DarkTurquoise"))) @@ -329,8 +352,9 @@ (defun erc-match-current-nick-p (nickuserhost msg) "Check whether the current nickname is in MSG. NICKUSERHOST will be ignored." - (and msg - (string-match (concat "\\b" (erc-current-nick) "\\b") msg))) + (with-syntax-table erc-match-syntax-table + (and msg + (string-match (concat "\\b" (erc-current-nick) "\\b") msg)))) (defun erc-match-pal-p (nickuserhost msg) "Check whether NICKUSERHOST is in `erc-pals'. --8<---------------cut here---------------end--------------->8--- -- lawrence mitchell <we...@gm...> |