emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: electric-pair-mode as a minor mode?


From: João Távora
Subject: Re: electric-pair-mode as a minor mode?
Date: Sun, 26 Apr 2015 11:28:36 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (darwin)

Lars Magne Ingebrigtsen <address@hidden> writes:

>> On a related subject, I was thinking of (require 'smiley) in message.el
>> to avoid a `message-smiley' variable (a list o strings), and just use
>> the cars of `smiley-regexp-alist'. Can that be problematic?
> Requiring smiley should be unproblematic, I think.

Not so, unfortunately. Requiring it eventually requires `message'
recursively. I tried with `eval-when-compile'. It works when compiling
message.el standalone, but not when making emacs (some interaction with
eager-macroexpansion, apparently):

How do I solve this?

João

PS: Here's what I tried:

diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 1371e70..fe2097e 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -2964,15 +2964,13 @@ See also `message-forbidden-properties'."
 
 (autoload 'ecomplete-setup "ecomplete") ;; for Emacs <23.
 
-(defvar message-smileys '(":-)" ":)"
-                          ":-(" ":("
-                          ";-)" ";)")
-  "A list of recognized smiley faces in `message-mode'.")
+(eval-when-compile (require 'smiley)) ;; for `smiley-regexp-alist,'
+                                      ;; `eval-when-compile' needed to
+                                      ;; prevent recursive require.
 
 (defun message--syntax-propertize (beg end)
   "Syntax-propertize certain message text specially."
-  (let ((citation-regexp (concat "^" message-cite-prefix-regexp ".*$"))
-        (smiley-regexp (regexp-opt message-smileys)))
+  (let ((citation-regexp (concat "^" message-cite-prefix-regexp ".*$")))
     (goto-char beg)
     (while (search-forward-regexp citation-regexp
                                   end 'noerror)
@@ -2982,11 +2980,14 @@ See also `message-forbidden-properties'."
                              `(syntax-table ,(string-to-syntax "<")))
         (add-text-properties end (min (1+ end) (point-max))
                              `(syntax-table ,(string-to-syntax ">")))))
-    (goto-char beg)
-    (while (search-forward-regexp smiley-regexp
-            end 'noerror)
-      (add-text-properties (match-beginning 0) (match-end 0)
-                           `(syntax-table ,(string-to-syntax "."))))))
+    (when (featurep 'smiley)
+      (mapc (lambda (smiley-regexp)
+              (goto-char beg)
+              (while (search-forward-regexp smiley-regexp
+                                            end 'noerror)
+                (add-text-properties (match-beginning 0) (match-end 0)
+                                     `(syntax-table ,(string-to-syntax ".")))))
+            (mapcar #'car smiley-regexp-alist)))))
 
 ;;;###autoload
 (define-derived-mode message-mode text-mode "Message"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]