mirror of
https://github.com/ryuslash/mode-icons.git
synced 2024-12-26 06:28:04 +01:00
Add narrow icon
This commit is contained in:
parent
8631548a87
commit
8de4cbe7c2
1 changed files with 41 additions and 4 deletions
|
@ -150,6 +150,7 @@ absolute path to ICON."
|
|||
("Octave" "octave" xpm)
|
||||
("AHK" "autohotkey" xpm)
|
||||
("Info" #xf05a FontAwesome)
|
||||
("Narrow" #xf066 FontAwesome)
|
||||
;; Diminished modes
|
||||
("\\(?:ElDoc\\|Anzu\\|SP\\|Guide\\|PgLn\\|Undo-Tree\\|Ergo.*\\|,\\|Isearch\\|Ind\\|Fly\\)" nil nil)
|
||||
)
|
||||
|
@ -203,6 +204,16 @@ the icon."
|
|||
:type '(repeat sexp)
|
||||
:group 'mode-icons)
|
||||
|
||||
(defcustom mode-icons-narrow-text-properties
|
||||
'('local-map
|
||||
'(keymap
|
||||
(mode-line keymap
|
||||
(mouse-2 . mode-line-widen)))
|
||||
'mouse-face 'mode-line-highlight 'help-echo "mouse-2: Remove narrowing from buffer")
|
||||
"List of text propeties to apply to narrowing buffer indicator."
|
||||
:type '(repeat sexp)
|
||||
:group 'mode-icons)
|
||||
|
||||
(defvar mode-icons-powerline-p nil)
|
||||
(defun mode-icons-need-update-p ()
|
||||
"Determine if the mode-icons need an update."
|
||||
|
@ -361,6 +372,17 @@ ICON-SPEC should be a specification from `mode-icons'."
|
|||
(concat " " (eval `(propertize ,mode ,@mode-icons-minor-mode-base-text-properties))))
|
||||
(split-string (format-mode-line minor-mode-alist))))))
|
||||
|
||||
(defun mode-icons--generate-narrow ()
|
||||
"Extracts all rich strings necessary for narrow indicator."
|
||||
(let (icon-spec)
|
||||
(delete " " (delete "" (mapcar (lambda(mode)
|
||||
(concat " " (eval `(propertize
|
||||
,(if (setq icon-spec (mode-icons-get-icon-spec mode))
|
||||
(mode-icons-propertize-mode mode icon-spec)
|
||||
mode)
|
||||
,@mode-icons-narrow-text-properties))))
|
||||
(split-string (format-mode-line "%n")))))))
|
||||
|
||||
;; Based on rich-minority by Artur Malabarba
|
||||
(defvar mode-icons--backup-construct nil)
|
||||
(defvar mode-icons--mode-line-construct
|
||||
|
@ -372,6 +394,11 @@ ICON-SPEC should be a specification from `mode-icons'."
|
|||
'(:eval (mode-icons--generate-major-mode-item))
|
||||
"Construct used to replace `mode-name'.")
|
||||
|
||||
(defvar mode-icons--narrow-backup-construct nil)
|
||||
(defvar mode-icons--narrow-construct
|
||||
'(:eval (mode-icons--generate-narrow))
|
||||
"Construct used to replace %n in `mode-line-modes'.")
|
||||
|
||||
(defun mode-icons-fix (&optional enable)
|
||||
"Fix mode-icons."
|
||||
(if enable
|
||||
|
@ -386,19 +413,29 @@ ICON-SPEC should be a specification from `mode-icons'."
|
|||
(and (listp x)
|
||||
(equal (car x) :propertize)
|
||||
(equal (cadr x) '("" mode-name))))
|
||||
mode-line-modes)))
|
||||
mode-line-modes))
|
||||
(place-narrow (cl-member-if
|
||||
(lambda(x)
|
||||
(and (stringp x) (string= "%n" x)))
|
||||
mode-line-modes)))
|
||||
(when place
|
||||
(setq mode-icons--backup-construct (car place))
|
||||
(setcar place mode-icons--mode-line-construct))
|
||||
(when place-major
|
||||
(setq mode-icons--major-backup-construct (car place-major))
|
||||
(setcar place-major mode-icons--major-construct)))
|
||||
(setcar place-major mode-icons--major-construct))
|
||||
(when place-narrow
|
||||
(setq mode-icons--narrow-backup-construct (car place-narrow))
|
||||
(setcar place-narrow mode-icons--narrow-construct)))
|
||||
(let ((place (member mode-icons--mode-line-construct mode-line-modes))
|
||||
(place-major (member mode-icons--major-backup-construct mode-line-modes)))
|
||||
(place-major (member mode-icons--major-backup-construct mode-line-modes))
|
||||
(place-narrow (member mode-icons--narrow-backup-construct mode-line-modes)))
|
||||
(when place
|
||||
(setcar place mode-icons--backup-construct))
|
||||
(when place-major
|
||||
(setcar place-major mode-icons--major-backup-construct)))))
|
||||
(setcar place-major mode-icons--major-backup-construct))
|
||||
(when place-narrow
|
||||
(setcar place-narrow mode-icons--narrow-backup-construct)))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode mode-icons-mode
|
||||
|
|
Loading…
Reference in a new issue