;;; gui-settings --- Summary ;;; Commentary: ;;; Requirements: ;; restart-emacs https://melpa.org/#/restart-emacs ;; dashboard https://melpa.org/#/dashboard ;; page-break-lines https://melpa.org/#/page-break-lines ;; all-the-icons https://melpa.org/#/all-the-icons ;; memoize https://melpa.org/#/memoize ;; indent-guide https://melpa.org/#/indent-guide ;; not highlight-indent-guides ;; rainbow-mode https://elpa.gnu.org/packages/rainbow-mode.html ;; focus https://melpa.org/#/focus ;; virtual-auto-fill https://melpa.org/#/virtual-auto-fill ;;; Code: (use-package emacs :delight (auto-fill-function "↵") (compilation-shell-minor-mode "Ⓒs") (eldoc-mode "Ⓔ") ;; Ⓔ e (visual-line-mode "↩") ;; " Wrap" (whitespace-mode "␣") ;; "␣ _ ws" ;; major modes (calendar-mode "🅒al") ;; "Calendar" "📆" (css-mode "🅒SS") ;; "CSS" (emacs-lisp-mode "🅛e") ;; "EL 🅛⒠" (eshell-mode "🅢e") ;; "Esh 🅔⒮" (fundamental-mode "🅕") ;; "F " ;; not working (help-mode "🅗") ;; "H " (Info-mode "🅘") ;; "I " ;; not working (latex-mode "🅛a") ;; "LaTeX " (lisp-interaction-mode "🅛i") ;; "LI 🅛⒤" (messages-mode "🅜") ;; "M " ;; not working (messages-buffer-mode "🅜") ;; "M " ;; not working (inferior-python-mode "🅟i") ;; "IPy 🅟⒤" :hook (prog-mode . display-fill-column-indicator-mode) (help-mode . visual-line-mode) (messages-buffer-mode . visual-line-mode) :config (set-face-attribute 'fill-column-indicator nil :foreground "DarkSlateGray") ;; inherit shadow ;; `scroll-bar-mode' sets for all frames and all windows ;; use `set-window-scroll-bars' for windows only (scroll-bar-mode 0) ;; 1st deactivate scrolling (add-hook 'visual-line-mode-hook 'my-visual-line-mode-hook) (defun my-visual-line-mode-hook () "no `horizontal-scroll-bar' if `visual-line-mode'" (if visual-line-mode (set-window-scroll-bars (frame-selected-window) nil t nil nil) (set-window-scroll-bars (frame-selected-window) nil t nil 'bottom) )) (add-hook 'window-state-change-hook (lambda () (my-window-state-change (window-buffer)))) (defun my-window-state-change (frame-or-window) (let (window (vertical-type nil) (horizontal-type nil) buffer buffer-name) (when (framep frame-or-window) (setq window (frame-selected-window frame-or-window))) (setq buffer (window-buffer window)) (setq buffer-name (buffer-name buffer)) ;; turn scrolling on (when visual-line-mode (setq vertical-type 'right) (setq horizontal-type nil)) (when truncate-lines (setq vertical-type 'right) (setq horizontal-type 'bottom)) ;; turn off (cond ((or (minibufferp buffer) (string-equal major-mode "doc-view-mode") (string-equal buffer-name " *Org tags*")) (setq vertical-type nil) (setq horizontal-type nil)) ((string-prefix-p "*mu4e" buffer-name) (setq vertical-type 'right))) ;; (message "%s %s %s %s %s" ;; buffer-name ;; visual-line-mode ;; truncate-lines ;; vertical-type ;; horizontal-type) (set-window-scroll-bars window nil vertical-type nil horizontal-type) ) ) ) (use-package doc-view :defer t :delight (doc-view-mode "🅓oc") ;; "DocView" :config (setq doc-view-continuous t)) (use-package restart-emacs) (use-package page-break-lines :delight (page-break-lines-mode "Ⓟb") :config (global-page-break-lines-mode)) (use-package memoize :defer t) (use-package all-the-icons :load-path (lambda() (concat user-emacs-directory "lisp/all-the-icons")) :defer t :config (when (and (not (my-font-installed-p "all-the-icons")) (window-system)) (all-the-icons-install-fonts t) ;;(restart-emacs) ;; infinity loop? )) (use-package dashboard :load-path (lambda() (concat user-emacs-directory "lisp/dashboard")) :delight (dashboard-mode "🅓") :config (setq dashboard-startup-banner 'logo) (setq dashboard-set-navigator t) ;; (setq dashboard-navigator-buttons ;; Format: "(icon title help action face prefix suffix)" ;; (list (list ;; line1 ;; ;; "☆" "Star" "Show stars" (lambda (&rest _) (show-stars)) warning "[" "]") ;; (list "?" "" "?/h" (lambda (&rest _) (describe-mode)) nil "<" ">") ;;#'show-help ;; ))) (setq dashboard-navigator-buttons ;; Format: "(icon title help action face prefix suffix)" `(( ;; views ("" "Custom Views:" "custom views" nil default "" "") (,(all-the-icons-fileicon "elisp" :height 1.0 :v-adjust -0.1) "ELisp" "my-view-elisp" (lambda (&rest _) (my-view-elisp))) (,(all-the-icons-alltheicon "python" :height 1.0 :v-adjust 0.0) "Python" "my-view-python" (lambda (&rest _) (my-view-python))) ) ( ;; major modes ("" "Major Modes:" "major modes" nil default "" "") ("" "Deft" "deft" (lambda (&rest _) (deft))) ("" "EShell" "eshell-mode" (lambda (&rest _) (eshell-mode))) ("" "Magit" "magit" (lambda (&rest _) (magit))) (,(all-the-icons-octicon "mail" :height 1.0 :v-adjust 0.0) "Mu4e" "mu4e" (lambda (&rest _) (mu4e))) (,(all-the-icons-octicon "mail" :height 1.0 :v-adjust 0.0) "Notmuch" "notmuch" (lambda (&rest _) (notmuch))) ("" "Org-Brain" "org-brain-visualize" (lambda (&rest _) (call-interactively 'org-brain-visualize))) ) ( ;; major modes second line ("" "Org-Drill" "org-drill" (lambda (&rest _) (org-drill))) ("" "Powershell" "powershell" (lambda (&rest _) (powershell))) ("" "Shell" "shell" (lambda (&rest _) (shell))) ("" "Treemacs" "treemacs" (lambda (&rest _) (treemacs))) ) ( ;; line1 ;; "☆" "Star" "Show stars" (lambda (&rest _) (show-stars)) warning "[" "]") (,(all-the-icons-material "help_outline" :height 1.1 :v-adjust -0.15) ;; all-the-icons-octicon "question" "Help" "?/h" (lambda (&rest _) (describe-mode)) nil) ;; #'show-help (,(all-the-icons-material "refresh" :height 1.1 :v-adjust -0.15) ;; all-the-icons-octicon "sync" "Restart" "restart-emacs" (lambda (&rest _) (restart-emacs)) nil) ))) (setq dashboard-items '((recents . 5) (bookmarks . 5) ;;(projects . 5) ;;(agenda . 5) (registers . 5))) ;;custom widget (defun my-widget-item (icon icon-face title title-face help action) (let ((action (or action #'ignore))) (widget-create 'item :tag (concat (propertize icon 'face `(:inherit ,(get-text-property 0 'face icon) :inherit ,icon-face)) (propertize " " 'face 'variable-pitch) (propertize title 'face title-face)) :help-echo help :action action :button-face `(:underline nil) :mouse-face 'highlight ;;:button-prefix (propertize "" 'face 'dashboard-navigator) ;;:button-suffix (propertize "" 'face 'dashboard-navigator) :format "%[%t%]"))) ;; (defun dashboard-insert-custom (list-size) ;; (dashboard-insert-shortcut "v" "Views" t) ;; (when (display-graphic-p) ;; (insert (all-the-icons-material "view_quilt" :height 1.6 :v-adjust -0.25 ;; :face 'dashboard-heading)) ;; (insert " ")) ;; (insert (propertize "Custom views:" 'face 'dashboard-heading)) ;; (insert " (v)") ;; (insert " ") ;; (my-widget-item (all-the-icons-fileicon "elisp" :height 1.0 :v-adjust -0.1) ;; 'all-the-icons-purple "ELisp" 'default "my-view-elisp" ;; (lambda (&rest _) (my-view-elisp))) ;; (insert " ") ;; (my-widget-item (all-the-icons-alltheicon "python" :height 1.0 :v-adjust 0.0) ;; 'all-the-icons-dblue "Python" 'default "my-view-python" ;; (lambda (&rest _) (my-view-python))) ;; (insert " ") ;; (my-widget-item (all-the-icons-octicon "mail" :height 1.0 :v-adjust 0.0) ;; 'all-the-icons-dblue "Notmuch" 'default "notmuch" ;; (lambda (&rest _) (notmuch))) ;; ) ;; (add-to-list 'dashboard-item-generators '(custom . dashboard-insert-custom) t) ;; see below add-to-list to dashboard-items ;; `clean-buffer-list' (defun my-buffer-name-list (&optional special internal) "If SPECIAL non-nil then include special buffers. If INTERNAL non-nil then include internal buffers." (let ((b-list (mapcar (function buffer-name) (buffer-list))) new-list head) (while b-list (setq head (car b-list)) (when (or internal ;; check if no space is in the fron (not (string= " " (substring head 0 1)))) (when (or special ;; check if no star are in the front and back (and (not (string= "*" (substring head 0 1))) (not (string= "*" (subseq head -1))))) (push head new-list))) (setq b-list (cdr b-list))) (nreverse new-list))) (defun my-buffer-name-list-special () "List special buffers." (let ((b-list (mapcar (function buffer-name) (buffer-list))) new-list head) (while b-list (setq head (car b-list)) (when (and (string= "*" (substring head 0 1)) (string= "*" (subseq head -1))) (push head new-list)) (setq b-list (cdr b-list))) (nreverse new-list))) ;; overwrite with addition parameter to supress the logic to insert ;; a pre-defined heading icon. This is used to include own icon. (defun dashboard-insert-heading (heading &optional shortcut suppress-icon) "Insert a widget HEADING in dashboard buffer, adding SHORTCUT if provided." (when (and (display-graphic-p) dashboard-set-heading-icons) ;; Try loading `all-the-icons' (unless (or (fboundp 'all-the-icons-octicon) (require 'all-the-icons nil 'noerror)) (error "Package `all-the-icons' isn't installed")) (unless suppress-icon ;; ADDED (insert (cond ((string-equal heading "Recent Files:") (all-the-icons-octicon (cdr (assoc 'recents dashboard-heading-icons)) :height 1.2 :v-adjust 0.0 :face 'dashboard-heading)) ((string-equal heading "Bookmarks:") (all-the-icons-octicon (cdr (assoc 'bookmarks dashboard-heading-icons)) :height 1.2 :v-adjust 0.0 :face 'dashboard-heading)) ((or (string-equal heading "Agenda for today:") (string-equal heading "Agenda for the coming week:")) (all-the-icons-octicon (cdr (assoc 'agenda dashboard-heading-icons)) :height 1.2 :v-adjust 0.0 :face 'dashboard-heading)) ((string-equal heading "Registers:") (all-the-icons-octicon (cdr (assoc 'registers dashboard-heading-icons)) :height 1.2 :v-adjust 0.0 :face 'dashboard-heading)) ((string-equal heading "Projects:") (all-the-icons-octicon (cdr (assoc 'projects dashboard-heading-icons)) :height 1.2 :v-adjust 0.0 :face 'dashboard-heading)) (t " "))) ) ;; ADDED (insert " ")) (insert (propertize heading 'face 'dashboard-heading)) (if shortcut (insert (format " (%s)" shortcut)))) ;; overwrite to supress the logic to insert a pre-defined heading ;; icon. This is used to include own icon. (defmacro my-dashboard-insert-section (section-name list list-size shortcut action &rest widget-params) "Add a section with SECTION-NAME and LIST of LIST-SIZE items to the dashboard. SHORTCUT is the keyboard shortcut used to access the section. ACTION is theaction taken when the user activates the widget button. WIDGET-PARAMS are passed to the \"widget-create\" function." `(progn (dashboard-insert-heading ,section-name (if (and ,list dashboard-show-shortcuts) ,shortcut) t) ;; ADDED (if ,list (when (dashboard-insert-section-list ,section-name (dashboard-subseq ,list 0 ,list-size) ,action ,@widget-params) (dashboard-insert-shortcut ,shortcut ,section-name)) (insert "\n --- No items ---")))) (defun dashboard-insert-buffers (list-size) "Add the list of LIST-SIZE items from buffers list. See also `dashboard-insert-section'." (when (display-graphic-p) (insert (all-the-icons-octicon "versions" :height 1.2 :v-adjust 0.0 :face 'dashboard-heading))) (my-dashboard-insert-section "Special Buffers:" ;;(my-buffer-name-list) (my-buffer-name-list-special) list-size "b" `(lambda (&rest ignore) (switch-to-buffer ,el)) (abbreviate-file-name el))) (add-to-list 'dashboard-item-generators '(buffers . dashboard-insert-buffers) t) ;; see below add-to-list to dashboard-items (add-to-list 'dashboard-items '(buffers . 5) t) ;; (add-to-list 'dashboard-items '(custom) t) ;; needs package ‘all-the-icons’ (setq dashboard-set-heading-icons t) (setq dashboard-set-file-icons t) (dashboard-setup-startup-hook)) (use-package indent-guide :delight (indent-guide-mode "Ⓘg") :hook (prog-mode . indent-guide-mode) ;; problem if used in notmuch :config (set-face-attribute 'indent-guide-face nil :foreground "DarkSlateGray") ;; foreground #535353 ;;(setq indent-guide-char ":") (setq indent-guide-char "\u2502") (setq indent-guide-recursive t) ;; NOT RECOMMENDED: To show not only one guide line but all guide lines recursively, set indent-guide-recursive non-nil. ) ;; problem when using 'character in elisp it inserts the guide characters when inserting text before guide characters ;; (use-package highlight-indent-guides ;; :delight (highlight-indent-guides-mode "Ⓘg") ;; :hook (prog-mode . highlight-indent-guides-mode) ;; :config ;; (setq highlight-indent-guides-method 'character) ;; 'fill 'character 'bitmap ;; (setq highlight-indent-guides-character ?:) ;; ?: ;; (setq highlight-indent-guides-auto-enabled nil) ;; deactivate auto colors ;; (set-face-foreground 'highlight-indent-guides-character-face "gray30") ;; ) (use-package rainbow-mode :delight (rainbow-mode "Ⓡ") ;; " Rbow" :commands rainbow-mode) (use-package focus :commands focus-mode :custom-face (focus-unfocused ((t :inherit shadow)))) (use-package virtual-auto-fill :delight (virtual-auto-fill-mode "Ⓥf") :commands virtual-auto-fill-mode ;;:hook (help-mode . virtual-auto-fill-mode) ) (provide 'gui-settings) ;;; gui-settings.el ends here