From: Francis L. <fr...@wo...> - 2005-01-17 12:34:15
|
ERCers, This proposed patch makes erc-button-face have priority over existing faces when erc-button.el buttonizes an URL. To see why this is an issue, eval this code, and then type /TOPIC in a channel that has URLs in its topic: (progn (require 'erc-button) (erc-button-mode 1) (set-face-foreground (make-face 'my-button-face) "yellow") (setq erc-button-face 'my-button-face) (set-face-foreground 'erc-notice-face "red")) The face of the URLs in the topic ends up being the list (erc-notice-face my-button-face) but with this patch, it would be (my-button-face erc-notice-face) giving priority to the button face. The reasoning here is that the button-ness of a button is more important than the notice-ness of a notice (or whatever the ambient text face may be). If I don't hear objections, in a few days I'm commit this patch. This patch also fixes a byte-compiler warning about too-few arguments in a call to `error'. -- Francis Litterio franl <at> world . std . com --- erc-button.el 16 Jan 2005 09:17:51 -0500 1.60 +++ erc-button.el 17 Jan 2005 07:11:50 -0500 @@ -1,4 +1,4 @@ -;;; erc-button.el --- A way of buttonizing certain things in ERC buffers +;; erc-button.el --- A way of buttonizing certain things in ERC buffers ;; Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003,2004 ;; Free Software Foundation, Inc. @@ -80,6 +80,14 @@ :type 'face :group 'erc-faces) +(defcustom erc-button-face-has-priority t + "Flag indicating whether erc-button-face overrides existing faces. + +If non-nil, buttons displayed with erc-button-face will have that face +merged into any existing faces on the button text with higher priority." + :type 'boolean + :group 'erc-faces) + (defcustom erc-button-url-regexp "\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=!?#$@~`%&*+\\/:;.,]+[-a-zA-Z0-9_=#$@~`%&*+\\/]" "Regular expression that matches URLs." :group 'erc-button @@ -360,7 +368,11 @@ ;; new face is a list containing FACE and the old stuff. end is ;; where this face changes. (while (< pos to) - (setq new (if old (append old (erc-list face)) face)) + (setq new (if old + (if erc-button-face-has-priority + (append (erc-list face) old) + (append old (erc-list face))) + face)) (put-text-property pos end 'face new) (setq pos end old (erc-list (get-text-property pos 'face)) @@ -389,7 +401,7 @@ (unless fun (message "No button at point")) (when (and fun (symbolp fun) (not (fboundp fun))) - (error "Function %S is not bound")) + (error "Function %S is not bound" fun)) (apply fun data))) (defun erc-button-next () |