branch: externals/matlab-mode
commit 37fe4ff5797a172b85c23146041da7e7cdc0cc4e
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>

    eieio lisp cleanups from Stefan Monnier
    
    See issue #60
---
 linemark.el | 75 ++++++++++++++++++++++++++-----------------------------------
 mlint.el    |  5 +++--
 2 files changed, 35 insertions(+), 45 deletions(-)

diff --git a/linemark.el b/linemark.el
index c2d502bf7e..3c469fe2d1 100644
--- a/linemark.el
+++ b/linemark.el
@@ -33,10 +33,9 @@
 ;; management can be a pain, and overlays are certainly needed for use
 ;; with font-lock.
 
-(eval-and-compile
-  (require 'matlab-compat))
-
+(require 'matlab-compat)
 (require 'eieio)
+(require 'eieio-base)
 
 ;;; Code:
 
@@ -45,39 +44,29 @@
   :group 'tools
   )
 
-(eval-and-compile
-  ;; These faces need to exist to show up as valid default
-  ;; entries in the classes defined below.
-
-  (defface linemark-stop-face '((((class color) (background light))
-                                 (:background "#ff8888"))
-                                (((class color) (background dark))
-                                 (:background "red3")))
-    "*Face used to indicate a STOP type line."
-    :group 'linemark)
-
-  (defface linemark-caution-face '((((class color) (background light))
-                                    (:background "yellow"))
-                                   (((class color) (background dark))
-                                    (:background "yellow4")))
-    "*Face used to indicate a CAUTION type line."
-    :group 'linemark)
-
-  (defface linemark-go-face '((((class color) (background light))
-                               (:background "#88ff88"))
+(defface linemark-stop-face '((((class color) (background light))
+                               (:background "#ff8888"))
                               (((class color) (background dark))
-                               (:background "green4")))
-    "*Face used to indicate a GO, or OK type line."
-    :group 'linemark)
+                               (:background "red3")))
+  "Face used to indicate a STOP type line.")
+
+(defface linemark-caution-face '((((class color) (background light))
+                                  (:background "yellow"))
+                                 (((class color) (background dark))
+                                  (:background "yellow4")))
+  "Face used to indicate a CAUTION type line.")
 
-  (defface linemark-funny-face '((((class color) (background light))
+(defface linemark-go-face '((((class color) (background light))
+                             (:background "#88ff88"))
+                            (((class color) (background dark))
+                             (:background "green4")))
+  "Face used to indicate a GO, or OK type line.")
+
+(defface linemark-funny-face '((((class color) (background light))
                                   (:background "cyan"))
                                  (((class color) (background dark))
                                   (:background "blue3")))
-    "*Face used for elements with no particular criticality."
-    :group 'linemark)
-
-  )
+    "Face used for elements with no particular criticality.")
 
 (defclass linemark-entry ()
   ((filename :initarg :filename
@@ -97,7 +86,7 @@
              :protection protected))
   "Track a file/line associations with overlays used for display.")
 
-(defclass linemark-group ()
+(defclass linemark-group (eieio-named)
   ((marks :initarg :marks
           :type list
           :initform nil
@@ -133,7 +122,7 @@ the new instantiation."
         (lmg linemark-groups))
     ;; Find an old group.
     (while (and (not foundgroup) lmg)
-      (if (string= name (eieio-object-name-string (car lmg)))
+      (if (string= name (slot-value (car lmg) 'object-name))
           (setq foundgroup (car lmg)))
       (setq lmg (cdr lmg)))
     ;; Which group to use.
@@ -141,7 +130,7 @@ the new instantiation."
         ;; Recycle the old group
         (setq newgroup foundgroup)
       ;; Create a new group
-      (setq newgroup (apply 'make-instance class name args))
+      (setq newgroup (apply #'make-instance class :object-name name args))
       (setq linemark-groups (cons newgroup linemark-groups)))
     ;; Return the group
     newgroup))
@@ -220,7 +209,7 @@ Call the new entries activate method."
       (if (bolp) (setq line (1+ line))))
     (setq args (plist-put args :filename file))
     (setq args (plist-put args :line line))
-    (let ((new-entry (apply 'linemark-new-entry g args)))
+    (let ((new-entry (apply #'linemark-new-entry g args)))
       (oset new-entry parent g)
       (oset new-entry face (or face (oref g face)))
       (oset g marks (cons new-entry (oref g marks)))
@@ -239,7 +228,7 @@ Call the new entries activate method."
   (ignore g)
   (let ((f (plist-get args :filename))
         (l (plist-get args :line)))
-    (apply 'linemark-entry (format "%s %d" f l)
+    (apply #'linemark-entry (format "%s %d" f l)
            args)))
 
 (cl-defmethod linemark-display ((g linemark-group) active-p)
@@ -284,7 +273,7 @@ Call the new entries activate method."
 
 (cl-defmethod linemark-delete ((g linemark-group))
   "Remove group G from linemark tracking."
-  (mapc 'linemark-delete (oref g marks))
+  (mapc #'linemark-delete (oref g marks))
   (setq linemark-groups (delete g linemark-groups)))
 
 (cl-defmethod linemark-delete ((e linemark-entry))
@@ -329,8 +318,8 @@ Call the new entries activate method."
           (linemark-display to nil))
       (setq o (cdr o)))))
 
-(add-hook 'find-file-hook 'linemark-find-file-hook)
-(add-hook 'kill-buffer-hook 'linemark-kill-buffer-hook)
+(add-hook 'find-file-hook #'linemark-find-file-hook)
+(add-hook 'kill-buffer-hook #'linemark-kill-buffer-hook)
 
 ;;; Demo mark tool: Emulate MS Visual Studio bookmarks
 ;;
@@ -420,10 +409,10 @@ Call the new entries activate method."
 \\[viss-bookmark-prev-buffer]   - Move to the previous bookmark.
 \\[viss-bookmark-clear-all-buffer] - Clear all bookmarks."
   (interactive)
-  (define-key global-map [(f2)] 'viss-bookmark-toggle)
-  (define-key global-map [(shift f2)] 'viss-bookmark-prev-buffer)
-  (define-key global-map [(control f2)] 'viss-bookmark-next-buffer)
-  (define-key global-map [(control shift f2)] 'viss-bookmark-clear-all-buffer)
+  (define-key global-map [(f2)] #'viss-bookmark-toggle)
+  (define-key global-map [(shift f2)] #'viss-bookmark-prev-buffer)
+  (define-key global-map [(control f2)] #'viss-bookmark-next-buffer)
+  (define-key global-map [(control shift f2)] #'viss-bookmark-clear-all-buffer)
   )
 
 (provide 'linemark)
diff --git a/mlint.el b/mlint.el
index 210c7eeb80..58f9c662a7 100644
--- a/mlint.el
+++ b/mlint.el
@@ -33,6 +33,7 @@
 (require 'matlab)
 (require 'matlab--access)
 
+(require 'eieio-base)
 (require 'linemark)
 
 (eval-when-compile
@@ -287,7 +288,7 @@ Warning ID's won't change between releases, unlike the 
warning messages.")
   "Create a group object for tracking linemark entries.
 Do not permit multiple groups with the same name."
   (let* ((name "mlint")
-         (newgroup (mlint-lm-group name :face 'linemark-go-face))
+         (newgroup (mlint-lm-group :face 'linemark-go-face))
          (foundgroup nil)
          (lmg linemark-groups))
     (while (and (not foundgroup) lmg)
@@ -345,7 +346,7 @@ ACTIVE-P if it should be made visible."
   ;; A bug in linemark prevents individual entry colors.
   ;; Fix the color here.
   (let ((wc (oref e warningcode)))
-    (oset e :face
+    (oset e face
           (cond ((eq wc 'major) 'linemark-stop-face)
                 ((eq wc 'medium) 'linemark-caution-face)
                 (t 'linemark-go-face))))

Reply via email to