branch: externals/matlab-mode
commit 3bbd36c45f7057b99131352d6d534fdb091b38e9
Author: John Ciolfi <john.ciolfi...@gmail.com>
Commit: John Ciolfi <john.ciolfi...@gmail.com>

    add matlab-comment-heading-face for "%% description" comments
---
 matlab-sections.el | 59 +++++++++++++++++++++++++++---------------------------
 matlab-syntax.el   | 34 +++++++++++++++++++++----------
 2 files changed, 53 insertions(+), 40 deletions(-)

diff --git a/matlab-sections.el b/matlab-sections.el
index 359bf1e409..2be88ba82d 100644
--- a/matlab-sections.el
+++ b/matlab-sections.el
@@ -55,7 +55,8 @@
   '((t :inherit font-lock-comment-face
        :overline t
        :height 1.25))
-  "Default face for the section separation line in matlab-sections-minor-mode."
+  "Face for \"%% code section\" headings in matlab-sections-minor-mode.
+This is the face used when demarcating code sections in MATLAB script files."
   :group 'matlab-sections)
 
 (defcustom matlab-sections-highlight-section t
@@ -115,11 +116,11 @@ followed by a description that doesn't end with \"%\"."
   :type 'face
   :group 'matlab-sections
   :set (lambda (symbol value)
-        (set symbol value)
-        (dolist (buffer (buffer-list))
-          (with-current-buffer buffer
-            (when matlab-sections-overlay
-              (overlay-put matlab-sections-overlay 'face 
matlab-sections-highlight-face))))))
+         (set symbol value)
+         (dolist (buffer (buffer-list))
+           (with-current-buffer buffer
+             (when matlab-sections-overlay
+               (overlay-put matlab-sections-overlay 'face 
matlab-sections-highlight-face))))))
 
 (defcustom matlab-sections-sticky-flag t
   "Non-nil means the matlab-sections mode highlight appears in all windows.
@@ -139,24 +140,24 @@ nil is returned if there is no code section."
            (r-start (save-excursion
                       (save-restriction
                         (widen)
-                       (end-of-line)
-                       (if (re-search-backward 
matlab-sections-section-break-regexp nil t)
-                           (progn (setq in-section t)
+                        (end-of-line)
+                        (if (re-search-backward 
matlab-sections-section-break-regexp nil t)
+                            (progn (setq in-section t)
                                    (goto-char (match-beginning 0))
-                                  (point))
-                         (point-min)))))
-          (r-end (save-excursion
+                                   (point))
+                          (point-min)))))
+           (r-end (save-excursion
                     (save-restriction
                       (widen)
-                     (end-of-line)
-                     (if (re-search-forward 
matlab-sections-section-break-regexp nil t)
-                         (progn (setq in-section t)
+                      (end-of-line)
+                      (if (re-search-forward 
matlab-sections-section-break-regexp nil t)
+                          (progn (setq in-section t)
                                  (goto-char (match-beginning 0))
-                                (point))
-                       (point-max))))))
+                                 (point))
+                        (point-max))))))
       (if in-section
           `(,r-start . ,r-end)
-       nil)
+        nil)
       )))
 
 ;; Navigation
@@ -169,8 +170,8 @@ bunch of times."
 
   (dotimes (_ (or arg 1))
     (let ((rngc (matlab-sections-range-function))
-         (rngp (save-excursion (matlab-sections-backward-section)
-                               (matlab-sections-range-function))))
+          (rngp (save-excursion (matlab-sections-backward-section)
+                                (matlab-sections-range-function))))
       (goto-char (car rngp))
       (kill-region (car rngc) (cdr rngc))
       (yank)
@@ -185,8 +186,8 @@ Optionally a prefix argument ARG can be provided for 
repeating it a
 
   (dotimes (_ (or arg 1))
     (let ((rngc (matlab-sections-range-function))
-         (rngn (save-excursion (matlab-sections-forward-section)
-                               (matlab-sections-range-function))))
+          (rngn (save-excursion (matlab-sections-forward-section)
+                                (matlab-sections-range-function))))
       (goto-char (cdr rngn))
       (kill-region (car rngc) (cdr rngc))
       (yank)
@@ -386,12 +387,12 @@ This is a noop if SKIP-NONINTERACTIVE is nil and 
`noninteractive' is t."
   "Activate the matlab-sections overlay on the current line."
   (if matlab-sections-minor-mode  ; Might be changed outside the mode function.
       (progn
-       (unless matlab-sections-overlay
-         (setq matlab-sections-overlay (make-overlay 1 1)) ; to be moved
-         (overlay-put matlab-sections-overlay 'face 
matlab-sections-highlight-face))
-       (overlay-put matlab-sections-overlay
-                    'window (unless matlab-sections-sticky-flag 
(selected-window)))
-       (matlab-sections-move-overlay matlab-sections-overlay))
+        (unless matlab-sections-overlay
+          (setq matlab-sections-overlay (make-overlay 1 1)) ; to be moved
+          (overlay-put matlab-sections-overlay 'face 
matlab-sections-highlight-face))
+        (overlay-put matlab-sections-overlay
+                     'window (unless matlab-sections-sticky-flag 
(selected-window)))
+        (matlab-sections-move-overlay matlab-sections-overlay))
     (matlab-sections-unhighlight)))
 
 (defun matlab-sections-unhighlight ()
@@ -480,4 +481,4 @@ See `matlab-sections-help' for details on MATLAB code 
sections."
 
 ;; LocalWords:  Nidish Narayanaa Balaji nidbid gmail cellbreak Hisch subr 
defface defcustom booleanp
 ;; LocalWords:  stringp dolist defun cdr progn cp dotimes rngc rngp rngn endp 
begp setq Keymap cntrl
-;; LocalWords:  keymap kbd defalias Ludlam zappo prev eobp bobp buf SPC noop 
mfile
+;; LocalWords:  keymap kbd defalias Ludlam zappo prev eobp bobp buf SPC noop 
mfile classdef's
diff --git a/matlab-syntax.el b/matlab-syntax.el
index 6f24b58cfe..676b223755 100644
--- a/matlab-syntax.el
+++ b/matlab-syntax.el
@@ -32,6 +32,17 @@
 
 ;;; Code:
 
+(defface matlab-comment-heading-face
+  '((t :inherit font-lock-comment-face
+       :overline t
+       :bold t))
+  "Face for \"%% code section\" headings when NOT in 
matlab-sections-minor-mode.
+
+Using \"%% code section\" heading in non-script files, for example,
+function's, classdef's, etc.  is useful to demarcate concepts and this face
+is used for that purpose."
+  :group 'matlab-sections)
+
 (defvar matlab-syntax-support-command-dual t
   "Non-nil means to support command dual for indenting and syntax highlight.
 Does not work well in classes with properties with datatypes.")
@@ -327,17 +338,18 @@ Called when comments found in 
`matlab--scan-line-for-unterminated-string'."
             'font-lock-string-face))
 
     ;; Not a string, must be a comment. Pick type of comment face to use.
-    (cond ((and (boundp 'matlab-sections-minor-mode) matlab-sections-minor-mode
-                (< (nth 8 pps) (point-max))
-                (= (char-after (1+ (nth 8 pps))) ?\%) ;; looking-at "%%"?
-                ;; Now see if we have a valid section start comment
-                (save-excursion
-                  (save-restriction
-                    (widen)
-                    (goto-char (nth 8 pps))
-                    (beginning-of-line)
-                    (looking-at matlab-sections-section-break-regexp))))
-          'matlab-sections-section-break-face)
+    (cond ((and (< (nth 8 pps) (point-max))
+                (= (char-after (1+ (nth 8 pps))) ?\%)) ;; looking-at "%%"?
+           ;; Now see if we have a valid section start comment
+           (if (and (boundp 'matlab-sections-minor-mode) 
matlab-sections-minor-mode
+                    (save-excursion
+                      (save-restriction
+                        (widen)
+                        (goto-char (nth 8 pps))
+                        (beginning-of-line)
+                        (looking-at matlab-sections-section-break-regexp))))
+               'matlab-sections-section-break-face
+             'matlab-comment-heading-face))
          ((and (< (nth 8 pps) (point-max))
                (= (char-after (1+ (nth 8 pps))) ?\#))
           'matlab-pragma-face)

Reply via email to