[gnus git] branch master updated: m0-11-210-gb00d326 =1= message.el: Improve sexp-based movement in message-mode

Katsumi <[email protected]> Sun, 12 Apr 2015 15:17:34 +0200
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  b00d326b3b8ec2294db2ba0b455122fd80cd02bb (commit)
      from  1c6a21a4400e5b04aeb7d1a2c93ed2af90163a47 (commit)


- Log -----------------------------------------------------------------
commit b00d326b3b8ec2294db2ba0b455122fd80cd02bb
Author: João Távora <[email protected]>
Date:   Sun Apr 12 13:17:08 2015 +0000

    message.el: 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.
    * message.el (message--syntax-propertize): New function.
    (message-mode): Set syntax-related vars.
    (message-smileys): New variable.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 60e67c9..ab7a2a8 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2015-04-12  João Távora  <[email protected]>
+
+	Improve sexp-based movement in message-mode
+	* message.el (message--syntax-propertize): New function.
+	(message-mode): Set syntax-related vars.d
+	(message-smileys): New variable.
+
 2015-04-10  Stefan Monnier  <[email protected]>
 
 	* gnus-art.el (gnus-hidden-properties): Simplify.
diff --git a/lisp/message.el b/lisp/message.el
index 992e237..5b44866 100644
--- a/lisp/message.el
+++ b/lisp/message.el
@@ -3005,6 +3005,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.
@@ -3107,7 +3131,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."

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog  |    7 +++++++
 lisp/message.el |   32 +++++++++++++++++++++++++++++++-
 2 files changed, 38 insertions(+), 1 deletion(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project