[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Erc-discuss] [PATCH] erc: prefer 'font-lock-face to 'face where appropr
From: |
Vivek Dasmohapatra |
Subject: |
[Erc-discuss] [PATCH] erc: prefer 'font-lock-face to 'face where appropriate |
Date: |
Thu, 10 Mar 2016 01:04:57 +0000 (GMT) |
User-agent: |
Alpine 2.02 (DEB 1266 2009-07-14) |
When inserting text into an erc buffer where font-locking is active
and the highlighting is ad-hoc (ie not determined by predefined rules
in font-lock-defaults, font-lock-keywords or similar) we should prefer
the 'font-lock-face property for better interoperability with any
other font-locking mechanisms that may be active.
Note that this does not require any alteration to code that
inspects the 'face property or looks for text property changes,
as 'font-lock-face is defined to be a fallback for the 'face
property in `char-property-alias-alist'.
* lisp/erc/erc-button.el (erc-button-add-face): ibid
* lisp/erc/erc-capab.el (erc-capab-identify-add-prefix): ibid
* lisp/erc/erc-dcc.el (erc-dcc-chat-parse-output): ibid
* lisp/erc/erc-goodies.el (erc-controls-propertize): ibid
* lisp/erc/erc-stamp.el (erc-format-timestamp): ibid
* lisp/erc/erc-track.el (erc-faces-in): ibid
* lisp/erc/erc.el (erc-load-irc-script-lines, erc-display-msg,
erc-display-command, erc-make-notice, erc-highlight-notice,
erc-format-my-nick, address@hidden, erc-format-privmessage,
erc-display-prompt, erc-display-message-highlight,
erc-log-irc-protocol): ibid
---
lisp/erc/erc-button.el | 10 +++++-----
lisp/erc/erc-capab.el | 3 ++-
lisp/erc/erc-dcc.el | 2 +-
lisp/erc/erc-goodies.el | 2 +-
lisp/erc/erc-match.el | 12 ++++++------
lisp/erc/erc-stamp.el | 3 ++-
lisp/erc/erc-track.el | 2 +-
lisp/erc/erc.el | 42 +++++++++++++++++++++---------------------
8 files changed, 39 insertions(+), 37 deletions(-)
diff --git a/lisp/erc/erc-button.el b/lisp/erc/erc-button.el
index 7d50919..f63ac17 100644
--- a/lisp/erc/erc-button.el
+++ b/lisp/erc/erc-button.el
@@ -390,9 +390,9 @@ REGEXP is the regular expression which matched for this
button."
;; merged correctly. If we use overlays, then redisplay will be
;; very slow with lots of buttons. This is why we manually merge
;; face text properties.
- (let ((old (erc-list (get-text-property from 'face)))
+ (let ((old (erc-list (get-text-property from 'font-lock-face)))
(pos from)
- (end (next-single-property-change from 'face nil to))
+ (end (next-single-property-change from 'font-lock-face nil to))
new)
;; old is the face at pos, in list form. It is nil if there is no
;; face at pos. If nil, the new face is FACE. If not nil, the
@@ -400,10 +400,10 @@ REGEXP is the regular expression which matched for this
button."
;; where this face changes.
(while (< pos to)
(setq new (if old (cons face old) face))
- (put-text-property pos end 'face new)
+ (put-text-property pos end 'font-lock-face new)
(setq pos end
- old (erc-list (get-text-property pos 'face))
- end (next-single-property-change pos 'face nil to)))))
+ old (erc-list (get-text-property pos 'font-lock-face))
+ end (next-single-property-change pos 'font-lock-face nil to)))))
;; widget-button-click calls with two args, we ignore the first.
;; Since Emacs runs this directly, rather than with
diff --git a/lisp/erc/erc-capab.el b/lisp/erc/erc-capab.el
index 4b956cc..1a93e21 100644
--- a/lisp/erc/erc-capab.el
+++ b/lisp/erc/erc-capab.el
@@ -191,7 +191,8 @@ PARSED is an `erc-parsed' response struct."
(re-search-forward (regexp-quote nickname) nil t))
(goto-char (match-beginning 0))
(insert (erc-propertize erc-capab-identify-prefix
- 'face 'erc-capab-identify-unidentified))))))
+ 'font-lock-face
+ 'erc-capab-identify-unidentified))))))
(defun erc-capab-identify-get-unidentified-nickname (parsed)
"Return the nickname of the user if unidentified.
diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el
index 1bf380d..9152527 100644
--- a/lisp/erc/erc-dcc.el
+++ b/lisp/erc/erc-dcc.el
@@ -1205,7 +1205,7 @@ other client."
(setq posn (match-end 0))
(erc-display-message
nil nil proc
- 'dcc-chat-privmsg ?n (erc-propertize erc-dcc-from 'face
+ 'dcc-chat-privmsg ?n (erc-propertize erc-dcc-from 'font-lock-face
'erc-nick-default-face) ?m line))
(setq erc-dcc-unprocessed-output (substring str posn)))))
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el
index 2a1d187..afe8c55 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -475,7 +475,7 @@ to a region in the current buffer."
(font-lock-prepend-text-property
from
to
- 'face
+ 'font-lock-face
(append (if boldp
'(erc-bold-face)
nil)
diff --git a/lisp/erc/erc-match.el b/lisp/erc/erc-match.el
index 1313ecc..4104a43 100644
--- a/lisp/erc/erc-match.el
+++ b/lisp/erc/erc-match.el
@@ -486,7 +486,7 @@ Use this defun with `erc-insert-modify-hook'."
nick-end)
(erc-put-text-property
nick-beg nick-end
- 'face match-face (current-buffer)))
+ 'font-lock-face match-face (current-buffer)))
;; Highlight the nick of the message, or the current
;; nick if there's no nick in the message (e.g. /NAMES
;; output)
@@ -495,17 +495,17 @@ Use this defun with `erc-insert-modify-hook'."
(if nick-end
(erc-put-text-property
nick-beg nick-end
- 'face match-face (current-buffer))
+ 'font-lock-face match-face (current-buffer))
(goto-char (+ 2 (or nick-end
(point-min))))
(while (re-search-forward match-regex nil t)
(erc-put-text-property (match-beginning 0) (match-end 0)
- 'face match-face))))
+ 'font-lock-face match-face))))
;; Highlight the whole message
((eq match-htype 'all)
(erc-put-text-property
(point-min) (point-max)
- 'face match-face (current-buffer)))
+ 'font-lock-face match-face (current-buffer)))
;; Highlight all occurrences of the word to be
;; highlighted.
((and (string= match-type "keyword")
@@ -521,7 +521,7 @@ Use this defun with `erc-insert-modify-hook'."
(while (re-search-forward regex nil t)
(erc-put-text-property
(match-beginning 0) (match-end 0)
- 'face face))))
+ 'font-lock-face face))))
match-regex))
;; Highlight all occurrences of our nick.
((and (string= match-type "current-nick")
@@ -530,7 +530,7 @@ Use this defun with `erc-insert-modify-hook'."
(point-min))))
(while (re-search-forward match-regex nil t)
(erc-put-text-property (match-beginning 0) (match-end 0)
- 'face match-face)))
+ 'font-lock-face match-face)))
;; Else twiddle your thumbs.
(t nil))
(run-hook-with-args
diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el
index a4c91ca..ee4e1d2 100644
--- a/lisp/erc/erc-stamp.el
+++ b/lisp/erc/erc-stamp.el
@@ -347,7 +347,8 @@ changed, it will then print it off to the right."
Return the empty string if FORMAT is nil."
(if format
(let ((ts (format-time-string format time)))
- (erc-put-text-property 0 (length ts) 'face 'erc-timestamp-face ts)
+ (erc-put-text-property 0 (length ts)
+ 'font-lock-face 'erc-timestamp-face ts)
(erc-put-text-property 0 (length ts) 'invisible 'timestamp ts)
(erc-put-text-property 0 (length ts)
'isearch-open-invisible 'timestamp ts)
diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el
index 4d8feb5..ef09376 100644
--- a/lisp/erc/erc-track.el
+++ b/lisp/erc/erc-track.el
@@ -984,7 +984,7 @@ is in `erc-mode'."
(cl-assert
(let ((str "is bold"))
(put-text-property 3 (length str)
- 'face '(bold erc-current-nick-face)
+ 'font-lock-face '(bold erc-current-nick-face)
str)
(erc-faces-in str)))
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 1a126a8..d286d82 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -2271,7 +2271,7 @@ and appears in face `erc-input-face' in the buffer."
(aref string
(1- (length string))))
"\n"))
- 'face 'erc-input-face)))))
+ 'font-lock-face 'erc-input-face)))))
(let ((orig-win (selected-window))
(debug-buffer-window (get-buffer-window (current-buffer) t)))
(when debug-buffer-window
@@ -2461,9 +2461,9 @@ See also `erc-make-notice'."
(t
(erc-put-text-property
0 (length string)
- 'face (or (intern-soft
- (concat "erc-" (symbol-name type) "-face"))
- "erc-default-face")
+ 'font-lock-face (or (intern-soft
+ (concat "erc-" (symbol-name type) "-face"))
+ "erc-default-face")
string)
string)))
@@ -3890,7 +3890,7 @@ If FACE is non-nil, it will be used to propertize the
prompt. If it is nil,
'front-sticky t
'read-only t))
(erc-put-text-property 0 (1- (length prompt))
- 'face (or face 'erc-prompt-face)
+ 'font-lock-face (or face 'erc-prompt-face)
prompt)
(insert prompt))
;; Set the input marker
@@ -4253,11 +4253,11 @@ and as second argument the event parsed as a vector."
(nick-face (if privp 'erc-nick-msg-face 'erc-nick-default-face))
(msg-face (if privp 'erc-direct-msg-face 'erc-default-face)))
;; add text properties to text before the nick, the nick and after the nick
- (erc-put-text-property 0 (length mark-s) 'face msg-face str)
+ (erc-put-text-property 0 (length mark-s) 'font-lock-face msg-face str)
(erc-put-text-property (length mark-s) (+ (length mark-s) (length nick))
- 'face nick-face str)
+ 'font-lock-face nick-face str)
(erc-put-text-property (+ (length mark-s) (length nick)) (length str)
- 'face msg-face str)
+ 'font-lock-face msg-face str)
str))
(defcustom erc-format-nick-function 'erc-format-nick
@@ -4294,7 +4294,7 @@ also `erc-format-nick-function'."
(let ((nick (erc-server-user-nickname user)))
(concat (erc-propertize
(erc-get-user-mode-prefix nick)
- 'face 'erc-nick-prefix-face)
+ 'font-lock-face 'erc-nick-prefix-face)
nick))))
(defun erc-format-my-nick ()
@@ -4305,12 +4305,12 @@ also `erc-format-nick-function'."
(nick (erc-current-nick))
(mode (erc-get-user-mode-prefix nick)))
(concat
- (erc-propertize open 'face 'erc-default-face)
- (erc-propertize mode 'face 'erc-my-nick-prefix-face)
- (erc-propertize nick 'face 'erc-my-nick-face)
- (erc-propertize close 'face 'erc-default-face)))
+ (erc-propertize open 'font-lock-face 'erc-default-face)
+ (erc-propertize mode 'font-lock-face 'erc-my-nick-prefix-face)
+ (erc-propertize nick 'font-lock-face 'erc-my-nick-face)
+ (erc-propertize close 'font-lock-face 'erc-default-face)))
(let ((prefix "> "))
- (erc-propertize prefix 'face 'erc-default-face))))
+ (erc-propertize prefix 'font-lock-face 'erc-default-face))))
(defun erc-echo-notice-in-default-buffer (s parsed buffer _sender)
"Echos a private notice in the default buffer, namely the
@@ -5231,10 +5231,10 @@ See also variable `erc-notice-highlight-type'."
(cond
((eq erc-notice-highlight-type 'prefix)
(erc-put-text-property 0 (length erc-notice-prefix)
- 'face 'erc-notice-face s)
+ 'font-lock-face 'erc-notice-face s)
s)
((eq erc-notice-highlight-type 'all)
- (erc-put-text-property 0 (length s) 'face 'erc-notice-face s)
+ (erc-put-text-property 0 (length s) 'font-lock-face 'erc-notice-face s)
s)
(t s)))
@@ -5246,7 +5246,7 @@ See also variable `erc-notice-highlight-type'."
(defun erc-highlight-error (s)
"Highlight error message S and return it."
- (erc-put-text-property 0 (length s) 'face 'erc-error-face s)
+ (erc-put-text-property 0 (length s) 'font-lock-face 'erc-error-face s)
s)
(defun erc-put-text-property (start end property value &optional object)
@@ -5436,7 +5436,7 @@ This returns non-nil only if we actually send anything."
(let ((beg (point)))
(insert line)
(erc-put-text-property beg (point)
- 'face 'erc-command-indicator-face)
+ 'font-lock-face 'erc-command-indicator-face)
(insert "\n"))
(when (processp erc-server-process)
(set-marker (process-mark erc-server-process) (point)))
@@ -5456,7 +5456,7 @@ current position."
(let ((beg (point)))
(insert line)
(erc-put-text-property beg (point)
- 'face 'erc-input-face))
+ 'font-lock-face 'erc-input-face))
(insert "\n")
(when (processp erc-server-process)
(set-marker (process-mark erc-server-process) (point)))
@@ -5880,7 +5880,7 @@ user input."
(setq args (substring args 1)))
;; prepare the prompt string for echo
(erc-put-text-property 0 (length sp)
- 'face 'erc-command-indicator-face sp)
+ 'font-lock-face 'erc-command-indicator-face sp)
(while lines
(setq s (car lines))
(erc-log (concat "erc-load-script: CMD: " s))
@@ -5890,7 +5890,7 @@ user input."
erc-script-echo)
(progn
(erc-put-text-property 0 (length line)
- 'face 'erc-input-face line)
+ 'font-lock-face 'erc-input-face line)
(erc-display-line (concat sp line) cb)))))
(setq lines (cdr lines)))))
--
2.1.4
- Re: [Erc-discuss] bug#5001: erc should use 'font-lock-face, not 'face, Vivek Dasmohapatra, 2016/03/06
- [Erc-discuss] [PATCH] erc: prefer 'font-lock-face to 'face where appropriate,
Vivek Dasmohapatra <=
- Re: [Erc-discuss] [PATCH] erc: prefer 'font-lock-face to 'face where appropriate, Lars Magne Ingebrigtsen, 2016/03/20
- Re: [Erc-discuss] [PATCH] erc: prefer 'font-lock-face to 'face where appropriate, Vivek Dasmohapatra, 2016/03/21
- Re: [Erc-discuss] [PATCH] erc: prefer 'font-lock-face to 'face where appropriate, Vivek Dasmohapatra, 2016/03/25
- Re: [Erc-discuss] [PATCH] erc: prefer 'font-lock-face to 'face where appropriate, Vivek Dasmohapatra, 2016/03/25
- Re: [Erc-discuss] [PATCH] erc: prefer 'font-lock-face to 'face where appropriate, Vivek Dasmohapatra, 2016/03/25
- Re: [Erc-discuss] [PATCH] erc: prefer 'font-lock-face to 'face where appropriate, Vivek Dasmohapatra, 2016/03/29
- Re: [Erc-discuss] [PATCH] erc: prefer 'font-lock-face to 'face where appropriate, Lars Magne Ingebrigtsen, 2016/03/25