summaryrefslogtreecommitdiff
path: root/lisp/gnus/message.el
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2015-04-12 13:12:27 +0100
committerJoão Távora <joaotavora@gmail.com>2015-04-12 13:29:05 +0100
commit25449e7296fe6e5cd9bca49ae1bc52d1552d5324 (patch)
treee0983372a3998c226b9d7d53d105a02f1600582e /lisp/gnus/message.el
parent303797134fa05d2e0d156a5bd912f8baab418489 (diff)
downloademacs-25449e7296fe6e5cd9bca49ae1bc52d1552d5324.tar.gz
Summary: Improve sexp-based movement in message-mode
Works by giving citations and smileys a different syntax. This helps modes like `show-paren-mode', `electric-pair-mode', and C-M-* sexp-based movement. * lisp/gnus/message.el (message--syntax-propertize): New function. (message-mode): Set syntax-related vars. (message-smileys): New variable. * test/automated/message-mode-tests.el: New file
Diffstat (limited to 'lisp/gnus/message.el')
-rw-r--r--lisp/gnus/message.el32
1 files changed, 31 insertions, 1 deletions
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 04145ded107..b1bee65b7fe 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -2961,6 +2961,30 @@ See also `message-forbidden-properties'."
(autoload 'ecomplete-setup "ecomplete") ;; for Emacs <23.
+(defvar message-smileys '(":-)" ":)"
+ ":-(" ":("
+ ";-)" ";)")
+ "A list of recognized smiley faces in `message-mode'.")
+
+(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)))
+ (goto-char beg)
+ (while (search-forward-regexp citation-regexp
+ end 'noerror)
+ (let ((start (match-beginning 0))
+ (end (match-end 0)))
+ (add-text-properties start (1+ start)
+ `(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 "."))))))
+
;;;###autoload
(define-derived-mode message-mode text-mode "Message"
"Major mode for editing mail and news to be sent.
@@ -3063,7 +3087,13 @@ M-RET `message-newline-and-reformat' (break the line and reformat)."
;; multibyte is not necessary at all. -- zsh
(mm-enable-multibyte))
(set (make-local-variable 'indent-tabs-mode) nil) ;No tabs for indentation.
- (mml-mode))
+ (mml-mode)
+ ;; Syntactic fontification. Helps `show-paren-mode',
+ ;; `electric-pair-mode', and C-M-* navigation by syntactically
+ ;; excluding citations and other artifacts.
+ ;;
+ (setq-local syntax-propertize-function 'message--syntax-propertize)
+ (setq-local parse-sexp-ignore-comments t))
(defun message-setup-fill-variables ()
"Setup message fill variables."