emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master 2c8e195 05/23: Implemented the actual minor mode


From: Artur Malabarba
Subject: [elpa] master 2c8e195 05/23: Implemented the actual minor mode
Date: Wed, 30 Sep 2015 12:15:58 +0000

branch: master
commit 2c8e195a261a64db5207f97e0618debdf779de1b
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>

    Implemented the actual minor mode
---
 rich-minority.el |   61 ++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/rich-minority.el b/rich-minority.el
index 744d83f..6e1b517 100644
--- a/rich-minority.el
+++ b/rich-minority.el
@@ -5,7 +5,7 @@
 ;; Author:  <address@hidden>
 ;; URL: http://github.com/Bruce-Connor/rich-minority
 ;; Version: 0.1
-;; Keywords: mode-line
+;; Keywords: mode-line faces
 ;; Prefix: rm
 ;; Separator: -
 
@@ -47,7 +47,7 @@
 (defconst rich-minority-version "0.1" "Version of the rich-minority.el 
package.")
 (defun rm-bug-report ()
   "Opens github issues page in a web browser. Please send any bugs you find.
-Please include your emacs and rich-minority versions."
+Please include your Emacs and rich-minority versions."
   (interactive)
   (message "Your rm-version is: %s, and your emacs version is: %s.\nPlease 
include this in your report!"
            rich-minority-version emacs-version)
@@ -57,7 +57,9 @@ Please include your emacs and rich-minority versions."
   (interactive)
   (customize-group 'rich-minority t))
 
-;;;###autoload
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Customization variables.
 (defcustom rm-excluded-modes '(" hl-p")
   "List of minor modes you want to hide from the mode-line.
 
@@ -128,18 +130,25 @@ These properties take priority over those defined in
   :group 'rich-minority
   :package-version '(rich-minority . "0.1"))
 
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Functions and Defvars
+(defconst rm--help-echo-bottom
+  "Mouse-1: Mode Menu.\nMouse-2: Mode Help.\nMouse-3: Toggle Minor Modes.")
+
+;;;###autoload
 (defun rm--mode-list-as-string-list ()
   "Return `minor-mode-list' as a simple list of strings."
   (let ((full-list (remove "" (mapcar #'format-mode-line minor-mode-alist))))
     (setq rm--help-echo
           (format "Full list:\n   %s\n\n%s"
                   (mapconcat 'identity full-list "\n   ")
-                  sml/major-help-echo))
+                  rm--help-echo-bottom))
     (mapcar #'rm--propertize
             (rm--remove-hidden-modes
              full-list))))
 
-(defvar-local rm--help-echo nil 
+(defvar-local rm--help-echo nil
   "Used to set the help-echo string dynamically.")
 
 (defcustom rm-base-text-properties
@@ -169,7 +178,7 @@ These properties take priority over those defined in
   (let ((pred (if (listp rm-excluded-modes) #'member #'rm--string-match))
         (out li))
     (when rm-excluded-modes
-      (setq out 
+      (setq out
             (remove nil
                     (mapcar
                      (lambda (x) (unless (and (stringp x)
@@ -178,7 +187,7 @@ These properties take priority over those defined in
                      out))))
     (when rm-included-modes
       (setq pred (if (listp rmm-included-modes) #'member #'rm--string-match))
-      (setq out 
+      (setq out
             (remove nil
                     (mapcar
                      (lambda (x) (unless (and (stringp x)
@@ -191,5 +200,41 @@ These properties take priority over those defined in
   "Like `string-match', but arg STRING comes before REGEXP."
   (string-match regexp string))
 
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; minor-mode
+(defvar rm--mode-line-construct
+  '(:eval (rm--mode-list-as-string-list))
+  "Construct used to replace `minor-mode-alist'.")
+
+(defvar rm--warning-absent-element
+  "Couldn't find %S inside `mode-line-modes'. If you didn't change it 
yourself, please file a bug report with M-x rm-bug-report"
+  "Warning message used when something wasn't found.")
+
+(defvar rm--backup-construct nil
+  "Construct containing `minor-mode-alist' which we removed from the 
mode-line.")
+
+;;;###autoload
+(define-minor-mode rich-minority-mode nil nil " $"
+  :global t
+  (if rich-minority-mode
+      (let ((place (or (member 'minor-mode-alist mode-line-modes)
+                       (member-if
+                        (lambda (x) (and (listp x)
+                                    (equal (car x) :propertize)
+                                    (equal (cadr x) '("" minor-mode-alist))))
+                        mode-line-modes))))
+        (if place
+            (progn
+              (setq rm--backup-construct (car place))
+              (setcar place rm--mode-line-construct))
+          (setq rich-minority-mode nil)
+          (warn rm--warning-absent-element 'minor-mode-alist)))
+    (let ((place (member rm--mode-line-construct mode-line-modes)))
+      (if place
+          (setcar place rm--backup-construct)
+        (warn rm--warning-absent-element rm--mode-line-construct)))))
+
 (provide 'rich-minority)
-;;; rich-minority.el ends here.
+
+;;; rich-minority.el ends here



reply via email to

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