diff options
-rw-r--r-- | basic.el | 255 | ||||
-rw-r--r-- | elisp.el | 237 | ||||
-rw-r--r-- | init.el | 42 | ||||
-rw-r--r-- | modeline.el | 144 | ||||
-rw-r--r-- | theme.el | 5 |
5 files changed, 373 insertions, 310 deletions
@@ -1,3 +1,5 @@ +;;; -*- lexical-binding: t; -*- + ;;; disable some default modes (tool-bar-mode -1) @@ -5,11 +7,23 @@ (scroll-bar-mode -1) (blink-cursor-mode -1) +;;; Use spaces instead of tabs + +(set 'indent-tabs-mode nil) + +;;; Don't make noise when saving files + +(setq save-silently t) + ;;; no title on the frame (setq frame-title-format "" icon-title-format "") +;;; major mode of the scratch buffer + +(set 'initial-major-mode 'emacs-lisp-mode) + ;;; echo quickly (setq echo-keystrokes 0.002) @@ -63,238 +77,19 @@ (setq-default display-line-numbers-type nil) (global-display-line-numbers-mode -1) -;;; package dir +;;; package management +;;;###autoload (defvar package-dir "/Users/durand/elisp_packages/" "The directory containing packages.") -;;; fontification of extra keywords in emacs lisp files - -(require 'advice) - -(font-lock-add-keywords - 'emacs-lisp-mode - `(("^;;;###\\(autoload\\)[ \n]" (1 font-lock-warning-face t)) - (emacs-lisp-highlight-vars-and-faces . emacs-lisp-face) - ("\\(\\(?:#'\\|['`]\\)\\)\\(?:[[:space:]]*\\(\\(?:\\sw\\|\\s_\\)+\\)\\)?" - (1 font-lock-keyword-face) - (2 font-lock-constant-face nil t)))) - -;;;###autoload -(defvar emacs-lisp-face nil - "The face used to highlight extra emacs lisp keywords.") - ;;;###autoload -(defun emacs-lisp-highlight-vars-and-faces (end) - (catch 'matcher - (while (re-search-forward "\\(?:\\sw\\|\\s_\\)+" end t) - (let ((ppss (save-excursion (syntax-ppss)))) - (cond ((nth 3 ppss) ; strings - (search-forward "\"" end t)) - ((nth 4 ppss) ; comments - (forward-line +1)) - ((let ((symbol (intern-soft (match-string-no-properties 0)))) - (and (cond ((null symbol) nil) - ((eq symbol t) nil) - ((keywordp symbol) nil) - ((special-variable-p symbol) - (setq emacs-lisp-face 'font-lock-variable-name-face)) - ((and (fboundp symbol) - (eq (char-before (match-beginning 0)) ?\() - (not (memq (char-before (1- (match-beginning 0))) - (list ?\' ?\`)))) - (let ((unaliased (indirect-function symbol))) - (cond ((or (macrop unaliased) - (special-form-p unaliased)) - (setq emacs-lisp-face 'font-lock-keyword-face)) - (t - (let (unadvised) - (while (not (eq (setq unadvised (ad-get-orig-definition unaliased)) - (setq unaliased (indirect-function unadvised))))) - unaliased) - (setq emacs-lisp-face - (if (subrp unaliased) - 'font-lock-constant-face - 'font-lock-function-name-face))))))) - (throw 'matcher t))))))) - nil)) - -;;; a better indentation - -(advice-add #'calculate-lisp-indent :override #'better-calculate-lisp-indent) - -;;;###autoload -(defun better-calculate-lisp-indent (&optional parse-start) - "Add better indentation for quoted and backquoted lists." - ;; This line because `calculate-lisp-indent-last-sexp` was defined with `defvar` - ;; with it's value ommited, marking it special and only defining it locally. So - ;; if you don't have this, you'll get a void variable error. - (defvar calculate-lisp-indent-last-sexp) - (save-excursion - (beginning-of-line) - (let ((indent-point (point)) - state - ;; setting this to a number inhibits calling hook - (desired-indent nil) - (retry t) - calculate-lisp-indent-last-sexp containing-sexp) - (cond ((or (markerp parse-start) (integerp parse-start)) - (goto-char parse-start)) - ((null parse-start) (beginning-of-defun)) - (t (setq state parse-start))) - (unless state - ;; Find outermost containing sexp - (while (< (point) indent-point) - (setq state (parse-partial-sexp (point) indent-point 0)))) - ;; Find innermost containing sexp - (while (and retry - state - (> (elt state 0) 0)) - (setq retry nil) - (setq calculate-lisp-indent-last-sexp (elt state 2)) - (setq containing-sexp (elt state 1)) - ;; Position following last unclosed open. - (goto-char (1+ containing-sexp)) - ;; Is there a complete sexp since then? - (if (and calculate-lisp-indent-last-sexp - (> calculate-lisp-indent-last-sexp (point))) - ;; Yes, but is there a containing sexp after that? - (let ((peek (parse-partial-sexp calculate-lisp-indent-last-sexp - indent-point 0))) - (if (setq retry (car (cdr peek))) (setq state peek))))) - (if retry - nil - ;; Innermost containing sexp found - (goto-char (1+ containing-sexp)) - (if (not calculate-lisp-indent-last-sexp) - ;; indent-point immediately follows open paren. - ;; Don't call hook. - (setq desired-indent (current-column)) - ;; Find the start of first element of containing sexp. - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) - (cond ((looking-at "\\s(") - ;; First element of containing sexp is a list. - ;; Indent under that list. - ) - ((> (save-excursion (forward-line 1) (point)) - calculate-lisp-indent-last-sexp) - ;; This is the first line to start within the containing sexp. - ;; It's almost certainly a function call. - (if (or - ;; Containing sexp has nothing before this line - ;; except the first element. Indent under that element. - (= (point) calculate-lisp-indent-last-sexp) - - ;; First sexp after `containing-sexp' is a keyword. This - ;; condition is more debatable. It's so that I can have - ;; unquoted plists in macros. It assumes that you won't - ;; make a function whose name is a keyword. - ;; (when-let (char-after (char-after (1+ containing-sexp))) - ;; (char-equal char-after ?:)) - - ;; Check for quotes or backquotes around. - (let* ((positions (elt state 9)) - (last (car (last positions))) - (rest (reverse (butlast positions))) - (any-quoted-p nil) - (point nil)) - (or - (when-let (char (char-before last)) - (or (char-equal char ?') - (char-equal char ?`))) - (progn - (while (and rest (not any-quoted-p)) - (setq point (pop rest)) - (setq any-quoted-p - (or - (when-let (char (char-before point)) - (or (char-equal char ?') - (char-equal char ?`))) - (save-excursion - (goto-char (1+ point)) - (looking-at-p - "\\(?:back\\)?quote[\t\n\f\s]+("))))) - any-quoted-p)))) - ;; Containing sexp has nothing before this line - ;; except the first element. Indent under that element. - nil - ;; Skip the first element, find start of second (the first - ;; argument of the function call) and indent under. - (progn (forward-sexp 1) - (parse-partial-sexp (point) - calculate-lisp-indent-last-sexp - 0 t))) - (backward-prefix-chars)) - (t - ;; Indent beneath first sexp on same line as - ;; `calculate-lisp-indent-last-sexp'. Again, it's - ;; almost certainly a function call. - (goto-char calculate-lisp-indent-last-sexp) - (beginning-of-line) - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp - 0 t) - (backward-prefix-chars))))) - ;; Point is at the point to indent under unless we are inside a string. - ;; Call indentation hook except when overridden by lisp-indent-offset - ;; or if the desired indentation has already been computed. - (let ((normal-indent (current-column))) - (cond ((elt state 3) - ;; Inside a string, don't change indentation. - nil) - ((and (integerp lisp-indent-offset) containing-sexp) - ;; Indent by constant offset - (goto-char containing-sexp) - (+ (current-column) lisp-indent-offset)) - ;; in this case calculate-lisp-indent-last-sexp is not nil - (calculate-lisp-indent-last-sexp - (or - ;; try to align the parameters of a known function - (and lisp-indent-function - (not retry) - (funcall lisp-indent-function indent-point state)) - ;; If the function has no special alignment - ;; or it does not apply to this argument, - ;; try to align a constant-symbol under the last - ;; preceding constant symbol, if there is such one of - ;; the last 2 preceding symbols, in the previous - ;; uncommented line. - (and (save-excursion - (goto-char indent-point) - (skip-chars-forward " \t") - (looking-at ":")) - ;; The last sexp may not be at the indentation - ;; where it begins, so find that one, instead. - (save-excursion - (goto-char calculate-lisp-indent-last-sexp) - ;; Handle prefix characters and whitespace - ;; following an open paren. (Bug#1012) - (backward-prefix-chars) - (while (not (or (looking-back "^[ \t]*\\|([ \t]+" - (line-beginning-position)) - (and containing-sexp - (>= (1+ containing-sexp) (point))))) - (forward-sexp -1) - (backward-prefix-chars)) - (setq calculate-lisp-indent-last-sexp (point))) - (> calculate-lisp-indent-last-sexp - (save-excursion - (goto-char (1+ containing-sexp)) - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) - (point))) - (let ((parse-sexp-ignore-comments t) - indent) - (goto-char calculate-lisp-indent-last-sexp) - (or (and (looking-at ":") - (setq indent (current-column))) - (and (< (line-beginning-position) - (prog2 (backward-sexp) (point))) - (looking-at ":") - (setq indent (current-column)))) - indent)) - ;; another symbols or constants not preceded by a constant - ;; as defined above. - normal-indent)) - ;; in this case calculate-lisp-indent-last-sexp is nil - (desired-indent) - (t - normal-indent)))))) +(defmacro use-package (package-path package-name &rest configs) + "Add PACKAGE-PATH to `load-path' and require PACKAGE-NAME. +The remaining CONFIGS are evaluated after the package is loaded." + (declare (indent 2) (debug defun)) + `(progn + (add-to-list 'load-path + (expand-file-name ,package-path ,package-dir)) + (require ,package-name) + ,@configs)) diff --git a/elisp.el b/elisp.el new file mode 100644 index 0000000..b1f1be4 --- /dev/null +++ b/elisp.el @@ -0,0 +1,237 @@ +;;; -*- lexical-binding: t; -*- + +;;; a simpler mode name + +(add-hook 'emacs-lisp-mode-hook + (lambda () (set 'mode-name "ELisp"))) + +;;; fontification of extra keywords in emacs lisp files + +(require 'advice) + +(font-lock-add-keywords + 'emacs-lisp-mode + `(("^;;;###\\(autoload\\)[ \n]" (1 font-lock-warning-face t)) + (emacs-lisp-highlight-vars-and-faces . emacs-lisp-face) + ("\\(\\(?:#'\\|['`]\\)\\)\\(?:[[:space:]]*\\(\\(?:\\sw\\|\\s_\\)+\\)\\)?" + (1 font-lock-keyword-face) + (2 font-lock-constant-face nil t)))) + +;;;###autoload +(defvar emacs-lisp-face nil + "The face used to highlight extra emacs lisp keywords.") + +;;;###autoload +(defun emacs-lisp-highlight-vars-and-faces (end) + (catch 'matcher + (while (re-search-forward "\\(?:\\sw\\|\\s_\\)+" end t) + (let ((ppss (save-excursion (syntax-ppss)))) + (cond ((nth 3 ppss) ; strings + (search-forward "\"" end t)) + ((nth 4 ppss) ; comments + (forward-line +1)) + ((let ((symbol (intern-soft (match-string-no-properties 0)))) + (and (cond ((null symbol) nil) + ((eq symbol t) nil) + ((keywordp symbol) nil) + ((special-variable-p symbol) + (setq emacs-lisp-face 'font-lock-variable-name-face)) + ((and (fboundp symbol) + (eq (char-before (match-beginning 0)) ?\() + (not (memq (char-before (1- (match-beginning 0))) + (list ?\' ?\`)))) + (let ((unaliased (indirect-function symbol))) + (cond ((or (macrop unaliased) + (special-form-p unaliased)) + (setq emacs-lisp-face 'font-lock-keyword-face)) + (t + (let (unadvised) + (while (not (eq (setq unadvised (ad-get-orig-definition unaliased)) + (setq unaliased (indirect-function unadvised))))) + unaliased) + (setq emacs-lisp-face + (if (subrp unaliased) + 'font-lock-constant-face + 'font-lock-function-name-face))))))) + (throw 'matcher t))))))) + nil)) + +;;; a better indentation + +(advice-add #'calculate-lisp-indent :override #'better-calculate-lisp-indent) + +;;;###autoload +(defun better-calculate-lisp-indent (&optional parse-start) + "Add better indentation for quoted and backquoted lists." + ;; This line because `calculate-lisp-indent-last-sexp` was defined with `defvar` + ;; with it's value ommited, marking it special and only defining it locally. So + ;; if you don't have this, you'll get a void variable error. + (defvar calculate-lisp-indent-last-sexp) + (save-excursion + (beginning-of-line) + (let ((indent-point (point)) + state + ;; setting this to a number inhibits calling hook + (desired-indent nil) + (retry t) + calculate-lisp-indent-last-sexp containing-sexp) + (cond ((or (markerp parse-start) (integerp parse-start)) + (goto-char parse-start)) + ((null parse-start) (beginning-of-defun)) + (t (setq state parse-start))) + (unless state + ;; Find outermost containing sexp + (while (< (point) indent-point) + (setq state (parse-partial-sexp (point) indent-point 0)))) + ;; Find innermost containing sexp + (while (and retry + state + (> (elt state 0) 0)) + (setq retry nil) + (setq calculate-lisp-indent-last-sexp (elt state 2)) + (setq containing-sexp (elt state 1)) + ;; Position following last unclosed open. + (goto-char (1+ containing-sexp)) + ;; Is there a complete sexp since then? + (if (and calculate-lisp-indent-last-sexp + (> calculate-lisp-indent-last-sexp (point))) + ;; Yes, but is there a containing sexp after that? + (let ((peek (parse-partial-sexp calculate-lisp-indent-last-sexp + indent-point 0))) + (if (setq retry (car (cdr peek))) (setq state peek))))) + (if retry + nil + ;; Innermost containing sexp found + (goto-char (1+ containing-sexp)) + (if (not calculate-lisp-indent-last-sexp) + ;; indent-point immediately follows open paren. + ;; Don't call hook. + (setq desired-indent (current-column)) + ;; Find the start of first element of containing sexp. + (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) + (cond ((looking-at "\\s(") + ;; First element of containing sexp is a list. + ;; Indent under that list. + ) + ((> (save-excursion (forward-line 1) (point)) + calculate-lisp-indent-last-sexp) + ;; This is the first line to start within the containing sexp. + ;; It's almost certainly a function call. + (if (or + ;; Containing sexp has nothing before this line + ;; except the first element. Indent under that element. + (= (point) calculate-lisp-indent-last-sexp) + + ;; First sexp after `containing-sexp' is a keyword. This + ;; condition is more debatable. It's so that I can have + ;; unquoted plists in macros. It assumes that you won't + ;; make a function whose name is a keyword. + ;; (when-let (char-after (char-after (1+ containing-sexp))) + ;; (char-equal char-after ?:)) + + ;; Check for quotes or backquotes around. + (let* ((positions (elt state 9)) + (last (car (last positions))) + (rest (reverse (butlast positions))) + (any-quoted-p nil) + (point nil)) + (or + (when-let (char (char-before last)) + (or (char-equal char ?') + (char-equal char ?`))) + (progn + (while (and rest (not any-quoted-p)) + (setq point (pop rest)) + (setq any-quoted-p + (or + (when-let (char (char-before point)) + (or (char-equal char ?') + (char-equal char ?`))) + (save-excursion + (goto-char (1+ point)) + (looking-at-p + "\\(?:back\\)?quote[\t\n\f\s]+("))))) + any-quoted-p)))) + ;; Containing sexp has nothing before this line + ;; except the first element. Indent under that element. + nil + ;; Skip the first element, find start of second (the first + ;; argument of the function call) and indent under. + (progn (forward-sexp 1) + (parse-partial-sexp (point) + calculate-lisp-indent-last-sexp + 0 t))) + (backward-prefix-chars)) + (t + ;; Indent beneath first sexp on same line as + ;; `calculate-lisp-indent-last-sexp'. Again, it's + ;; almost certainly a function call. + (goto-char calculate-lisp-indent-last-sexp) + (beginning-of-line) + (parse-partial-sexp (point) calculate-lisp-indent-last-sexp + 0 t) + (backward-prefix-chars))))) + ;; Point is at the point to indent under unless we are inside a string. + ;; Call indentation hook except when overridden by lisp-indent-offset + ;; or if the desired indentation has already been computed. + (let ((normal-indent (current-column))) + (cond ((elt state 3) + ;; Inside a string, don't change indentation. + nil) + ((and (integerp lisp-indent-offset) containing-sexp) + ;; Indent by constant offset + (goto-char containing-sexp) + (+ (current-column) lisp-indent-offset)) + ;; in this case calculate-lisp-indent-last-sexp is not nil + (calculate-lisp-indent-last-sexp + (or + ;; try to align the parameters of a known function + (and lisp-indent-function + (not retry) + (funcall lisp-indent-function indent-point state)) + ;; If the function has no special alignment + ;; or it does not apply to this argument, + ;; try to align a constant-symbol under the last + ;; preceding constant symbol, if there is such one of + ;; the last 2 preceding symbols, in the previous + ;; uncommented line. + (and (save-excursion + (goto-char indent-point) + (skip-chars-forward " \t") + (looking-at ":")) + ;; The last sexp may not be at the indentation + ;; where it begins, so find that one, instead. + (save-excursion + (goto-char calculate-lisp-indent-last-sexp) + ;; Handle prefix characters and whitespace + ;; following an open paren. (Bug#1012) + (backward-prefix-chars) + (while (not (or (looking-back "^[ \t]*\\|([ \t]+" + (line-beginning-position)) + (and containing-sexp + (>= (1+ containing-sexp) (point))))) + (forward-sexp -1) + (backward-prefix-chars)) + (setq calculate-lisp-indent-last-sexp (point))) + (> calculate-lisp-indent-last-sexp + (save-excursion + (goto-char (1+ containing-sexp)) + (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) + (point))) + (let ((parse-sexp-ignore-comments t) + indent) + (goto-char calculate-lisp-indent-last-sexp) + (or (and (looking-at ":") + (setq indent (current-column))) + (and (< (line-beginning-position) + (prog2 (backward-sexp) (point))) + (looking-at ":") + (setq indent (current-column)))) + indent)) + ;; another symbols or constants not preceded by a constant + ;; as defined above. + normal-indent)) + ;; in this case calculate-lisp-indent-last-sexp is nil + (desired-indent) + (t + normal-indent)))))) @@ -1,19 +1,51 @@ -;;; macro to conveniently load files +;;; -*- lexical-binding: t; -*- + +;;; garbage collection threshold maneuvre + +(setq gc-cons-threshold (* 512 1024 1024)) + +;;; tell me the start time at start-up + +;;;###autoload +(defun message-start-time () + "Tell me the start time at start-up." + (interactive) + (message "%s" (emacs-init-time))) + +(add-hook 'emacs-startup-hook #'message-start-time) + +;;; Macro to conveniently load files ;;;###autoload -(defvar load-file-directory (cond ((stringp load-file-name) - (file-name-directory load-file-name)) - (t default-directory)) +(defvar load-file-directory (cond ((stringp load-file-name) (file-name-directory load-file-name)) + (t default-directory)) "The directory to load files") +;;;###autoload (defun load-config (file-name) "Conviently load configuration files in the same directory as this file." (load-file (expand-file-name file-name load-file-directory))) +;;;###autoload +(defun load-config-later (file-name seconds) + "Load FILE-NAME SECONDS later." + (run-with-idle-timer seconds nil (lambda () (load-config file-name)))) + +;;;###autoload +(defmacro prepare-in-hook-once (entry-name hook file) + "Define a function called ENTRY-NAME that loads FILE in HOOK once." + `(progn + (defun ,entry-name () + (remove-hook ',hook ',entry-name) + (load-config ,file)) + (add-hook ',hook ',entry-name))) + (load-config "basic.el") (load-config "theme.el") -;; (load-config "modeline.el") +(load-config "modeline.el") +(prepare-in-hook-once prepare-elisp emacs-lisp-mode-hook "elisp.el") +(setq gc-cons-threshold (* 2 1024 1024)) diff --git a/modeline.el b/modeline.el index 54bee5c..3fce55c 100644 --- a/modeline.el +++ b/modeline.el @@ -92,9 +92,9 @@ MAP is the local keymap of the text." "Refresh the focus state of the mode line." (setq modeline-active-window nil) (mapc (lambda (frame) - (cond ((eq (frame-focus-state frame) t) - (setq modeline-active-window (modeline-get-active-window frame))))) - (frame-list))) + (cond ((eq (frame-focus-state frame) t) + (setq modeline-active-window (modeline-get-active-window frame))))) + (frame-list))) (add-hook 'window-configuration-change-hook #'modeline-set-active-window) (add-hook 'buffer-list-update-hook #'modeline-set-active-window) @@ -134,9 +134,9 @@ MAP is the local keymap of the text." (defun modeline-spc () "A space with the appropriate face." (format-mode-line " " - (cond ((modeline-active-window-p) - 'mode-line) - (t 'mode-line-inactive)))) + (cond ((modeline-active-window-p) + 'mode-line) + (t 'mode-line-inactive)))) ;;;###autoload (defvar modeline-bar-width 3 @@ -226,8 +226,8 @@ W is the width, H is the height of the bar." data ",\n") "\n};") 'xpm t :ascent 'center)))) - modeline-bar-img-inactive - (propertize + modeline-bar-img-inactive + (propertize " " 'display (let ((data (make-list modeline-bar-height (make-list modeline-bar-width 97))) @@ -254,7 +254,7 @@ W is the width, H is the height of the bar." ((and (display-graphic-p) (image-type-available-p 'xpm)) (cond ((modeline-active-window-p) modeline-bar-img) - (t modeline-bar-img-inactive))))) + (t modeline-bar-img-inactive))))) ;;;###autoload (defun modeline-format-buffer-status () @@ -264,23 +264,23 @@ W is the width, H is the height of the bar." ;; modified or not (cond ((and buffer-file-name (buffer-modified-p)) (format-mode-line "M" (cond - (active-p - 'doom-modeline-buffer-modified) - (t 'mode-line-inactive))))) + (active-p + 'doom-modeline-buffer-modified) + (t 'mode-line-inactive))))) ;; read-only? (cond (buffer-read-only (format-mode-line "R" (cond - (active-p - 'doom-modeline-urgent) - (t 'mode-line-inactive))))) + (active-p + 'doom-modeline-urgent) + (t 'mode-line-inactive))))) ;; narrow? (cond ((buffer-narrowed-p) (format-mode-line "N" (cond - (active-p - 'doom-modeline-warning) - (t 'mode-line-inactive)))))))) + (active-p + 'doom-modeline-warning) + (t 'mode-line-inactive)))))))) ;;;###autoload (defun modeline-format-position () @@ -288,11 +288,11 @@ W is the width, H is the height of the bar." (modeline-propertize (format-mode-line (concat "%l:%C " - (let ((orig (format-mode-line "%p"))) - (cond - ((memq (aref orig 0) (number-sequence 48 57)) - (concat orig "%%%")) - (t (substring orig 0 3))))) + (let ((orig (format-mode-line "%p"))) + (cond + ((memq (aref orig 0) (number-sequence 48 57)) + (concat orig "%%%")) + (t (substring orig 0 3))))) (cond ((modeline-active-window-p) 'mode-line) (t 'mode-line-inactive))) @@ -321,7 +321,7 @@ W is the width, H is the height of the bar." (let ((map (make-sparse-keymap))) (define-key map [mode-line mouse-1] #'ibuffer) (setq mode-line-buffer-identification-keymap - map)) + map)) ;;;###autoload (defun modeline-format-buffer-name () @@ -330,20 +330,20 @@ This will be displayed in the mode line." (declare (pure t) (side-effect-free t)) (modeline-propertize (let ((orig - (format-mode-line - "%b" (cond ((modeline-active-window-p) - 'mode-line-buffer-id) - (t 'mode-line-inactive))))) + (format-mode-line + "%b" (cond ((modeline-active-window-p) + 'mode-line-buffer-id) + (t 'mode-line-inactive))))) (cond ((> (length orig) modeline-buffer-name-len-max) (concat - (substring orig 0 (- modeline-buffer-name-len-max 3)) - "...")) + (substring orig 0 (- modeline-buffer-name-len-max 3)) + "...")) (t orig))) nil (concat (buffer-file-name) - "\n" - "mouse-1: ibuffer") + "\n" + "mouse-1: ibuffer") mode-line-buffer-identification-keymap)) ;;;###autoload @@ -354,14 +354,14 @@ This will be displayed in the mode line." (format-mode-line "%m" (cond ((modeline-active-window-p) - 'doom-modeline-buffer-major-mode) - (t 'mode-line-inactive))) + 'doom-modeline-buffer-major-mode) + (t 'mode-line-inactive))) nil "Major mode\nmouse-1: Display major mode menu\nmouse-2: Show help for major mode\nmouse-3: Toggle minor modes" mode-line-major-mode-keymap)) ;;;###autoload -(defvar modeline-vcs-str "" +(defvar-local modeline-vcs-str "" "Display the version control system information on the mode line.") ;;;###autoload (defvar modeline-vcs-length-max 12 @@ -376,41 +376,41 @@ This will be displayed in the mode line." (cond ((and vc-mode bfn) (let* ((backend (vc-backend bfn)) - (state (vc-state bfn backend)) - (indicator (cond - ((memq state '(added edited)) - (format-mode-line - "* " 'doom-modeline-info)) - ((eq state 'needs-merge) - (format-mode-line - "? " 'doom-modeline-info)) - ((eq state 'needs-update) - (format-mode-line - "! " 'doom-modeline-warning)) - ((memq state '(removed conflict unregistered)) - (format-mode-line - "! " 'doom-modeline-urgent)) - (t (format-mode-line - "@ " 'doom-modeline-info)))) - (str (cond (vc-display-status - (substring vc-mode (+ (cond ((eq backend 'Hg) 2) - (t 3)) - 2))) - (t "")))) - (concat - indicator - (propertize - (cond - ((> (length str) modeline-vcs-length-max) - (concat (substring str 0 (- modeline-vcs-length-max 3)) - "...")) - (t str)) - 'face (cond - ((eq state 'needs-update) - 'doom-modeline-warning) - ((memq state '(removed conflict unregistered)) - 'doom-modeline-urgent) - (t 'doom-modeline-info)))))) + (state (vc-state bfn backend)) + (indicator (cond + ((memq state '(added edited)) + (format-mode-line + "* " 'doom-modeline-info)) + ((eq state 'needs-merge) + (format-mode-line + "? " 'doom-modeline-info)) + ((eq state 'needs-update) + (format-mode-line + "! " 'doom-modeline-warning)) + ((memq state '(removed conflict unregistered)) + (format-mode-line + "! " 'doom-modeline-urgent)) + (t (format-mode-line + "@ " 'doom-modeline-info)))) + (str (cond (vc-display-status + (substring vc-mode (+ (cond ((eq backend 'Hg) 2) + (t 3)) + 2))) + (t "")))) + (concat + indicator + (propertize + (cond + ((> (length str) modeline-vcs-length-max) + (concat (substring str 0 (- modeline-vcs-length-max 3)) + "...")) + (t str)) + 'face (cond + ((eq state 'needs-update) + 'doom-modeline-warning) + ((memq state '(removed conflict unregistered)) + 'doom-modeline-urgent) + (t 'doom-modeline-info)))))) (t ""))))) (add-hook 'find-file-hook #'modeline-update-vcs-str) @@ -423,13 +423,13 @@ This will be displayed in the mode line." (declare (pure t) (side-effect-free t)) (cond ((and (stringp modeline-vcs-str) - (not (string= modeline-vcs-str ""))) + (not (string= modeline-vcs-str ""))) (concat (modeline-spc) (modeline-propertize (cond ((modeline-active-window-p) - modeline-vcs-str) + modeline-vcs-str) (t (propertize modeline-vcs-str 'face 'mode-line-inactive))) nil (get-text-property 1 'help-echo vc-mode) @@ -38,7 +38,6 @@ modus-operandi-theme-scale-4 1.2 modus-operandi-theme-scale-5 1.3) -(add-to-list 'load-path (expand-file-name "protesilaos/modus-themes" package-dir)) +(use-package "protesilaos/modus-themes" 'modus-vivendi-theme + (load-theme 'modus-vivendi t)) -(require 'modus-vivendi-theme) -(load-theme 'modus-vivendi t) |