summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--smart-documents.org186
1 files changed, 80 insertions, 106 deletions
diff --git a/smart-documents.org b/smart-documents.org
index e442bb1..1b09768 100644
--- a/smart-documents.org
+++ b/smart-documents.org
@@ -431,24 +431,12 @@ The following bindings lead to more natural window & frame exit behaviors.
(previous-buffer))))
#+END_SRC
-*** Header line commands
-
-#+BEGIN_SRC emacs-lisp :tangle no
- (global-set-key (kbd "<header-line> <mouse-1>")
- (lambda ()
- "Delete window; if sole window, previous buffer."
- (interactive)
- (if (> (length (window-list)) 1)
- (delete-window)
- (previous-buffer))))
-#+END_SRC
-
** Frame
*** Make new frame
#+BEGIN_SRC emacs-lisp :tangle yes
- (global-set-key [f5] 'make-frame)
+ (global-set-key (kbd "C-n") 'make-frame)
#+END_SRC
*** Make only frame
@@ -990,30 +978,6 @@ We hide minor modes in the mode line.
(setf rm-whitelist "projectile")
#+END_SRC
-This interpretation of the ideal mode line is the result of
-carefully studying the default ~mode-line~, as well as studying
-various customizations online.
-
-#+BEGIN_SRC emacs-lisp :tangle yes
- ;; (%e mode-line-front-space mode-line-mule-info mode-line-client
- ;; mode-line-modified mode-line-remote
- ;; mode-line-frame-identification mode-line-buffer-identification
- ;; mode-line-position (vc-mode vc-mode) mode-line-modes
- ;; mode-line-misc-info mode-line-end-spaces)
-
- (setq-default mode-line-format
- (list
- mode-line-front-space
- '(:eval (if buffer-read-only
- (propertize "🔒" 'help-echo "C-x C-q: unlock buffer.")
- (propertize "🔓" 'help-echo "C-x C-q: lock buffer.")))
- '(:eval (if (buffer-modified-p)
- (propertize " 🖉 " 'help-echo "Buffer is modified.")
- (propertize " ✓ " 'help-echo "Buffer is saved.")))
- mode-line-buffer-identification " "
- mode-line-modes " "
- mode-line-end-spaces))
-#+END_SRC
*** Emojis
@@ -1488,82 +1452,92 @@ way for UI elements which may be animated.
#+END_SRC
-**** TODO Header line
-# Figure out how to do 'keymap cleanly
+**** Header line
In Org mode, the document header line will be the title of the
-document we are working on currently.
+document we are working on currently. We start by defining
+keybindings for our header line buttons for navigating through
+open windows.
+
+#+BEGIN_SRC emacs-lisp :tangle yes
+ (defvar sd-header-line-previous-buffer-keymap
+ ;; Add menu of window navigation to the header line.
+ (let ((map (make-sparse-keymap)))
+ (define-key map [header-line mouse-1] 'previous-buffer)
+ map)
+ "Keymap for what is displayed in the header line, with a single window.")
+
+ (defvar sd-header-line-kill-buffer-keymap
+ ;; Close current buffer and window.
+ (let ((map (make-sparse-keymap)))
+ (define-key map [header-line mouse-1] 'kill-buffer-and-window)
+ map)
+ "Keymap for closing current window.")
+
+ (defvar sd-header-line-maximize-window-keymap
+ ;; Maximize current window.
+ (let ((map (make-sparse-keymap)))
+ (define-key map [header-line mouse-1] 'delete-other-windows)
+ map)
+ "Keymap for maximizing the current window.")
+
+ (defvar sd-header-line-minimize-window-keymap
+ (let ((map (make-sparse-keymap)))
+ (define-key map [header-line mouse-1] 'delete-window)
+ map)
+ "Keymap for minimizing the current window.")
+#+END_SRC
+
+Now, we describe the actual format of the header line.
+
+#+BEGIN_SRC emacs-lisp :tangle yes
+ (setq-default header-line-format
+ '(:eval
+ (list
+ (if (eq (length (window-list)) 1)
+ (propertize " ↤ "
+ 'face 'org-special-keyword
+ 'mouse-face 'highlight
+ 'keymap sd-header-line-previous-buffer-keymap
+ 'help-echo "Return to previous window.")
+ (list (propertize " ❌ "
+ 'face 'org-special-keyword
+ 'mouse-face 'org-todo
+ 'keymap sd-header-line-kill-buffer-keymap
+ 'help-echo "Close this window.")
+ (propertize " ⇱"
+ 'face 'org-special-keyword
+ 'mouse-face 'highlight
+ 'keymap sd-header-line-maximize-window-keymap
+ 'help-echo "Maximize this window.")
+ (propertize "⇲ "
+ 'face 'org-special-keyword
+ 'mouse-face 'highlight
+ 'keymap sd-header-line-minimize-window-keymap
+ 'help-echo "Minimize this window.")))
+ mode-line-buffer-identification)))
-#+BEGIN_SRC emacs-lisp :tangle no
-(setq header-line-format ; This will be our experimental header line.
- (list
- (propertize "..." 'display sd-icon-loading)
- '(:eval
- (list
- (if (eq (length (window-list)) 1)
- (propertize " ↤ " 'mouse-face 'highlight
- 'face 'org-special-keyword
- 'local-map 'previous-buffer
- 'help-echo "Return to previous window.")
- (list (propertize " ❌ " 'mouse-face 'org-todo
- 'face 'org-special-keyword
- 'help-echo "Close this window.")
- (propertize " ⇱" 'mouse-face 'highlight
- 'face 'org-special-keyword
- 'help-echo "Maximize this window.")
- (propertize "⇲ " 'mouse-face 'highlight
- 'face 'org-special-keyword
- 'help-echo "Minimize this window.")))
- (if (eq major-mode 'org-mode)
- (org-property-value "TITLE")
- (buffer-name))))))
-
- (setq sd-header-windows-nt ; This will be our fallback header line.
- (list
- '(:eval
- (list
- (if (eq (length (window-list)) 1)
- (propertize " ↤ " 'mouse-face 'highlight
- 'face 'org-special-keyword
- 'local-map 'previous-buffer
- 'help-echo "Return to previous window.")
- (list (propertize " ❌ " 'mouse-face 'org-todo
- 'face 'org-special-keyword
- 'help-echo "Close this window.")
- (propertize " ⇱" 'mouse-face 'highlight
- 'face 'org-special-keyword
- 'help-echo "Maximize this window.")
- (propertize "⇲ " 'mouse-face 'highlight
- 'face 'org-special-keyword
- 'help-echo "Minimize this window.")))
- (if (eq major-mode 'org-mode)
- (org-property-value "TITLE")
- (buffer-name))))))
-
- ;; (cond ((string-equal system-type "windows-nt")
- ;; (setq header-line-format sd-header-windows-nt))
- ;; ((string-equal system-type "gnu/linux")
- ;; (setq header-line-format sd-header-gnu-linux)))
-
- ;; Ensure our icons are animated on start
(image-animate sd-icon-loading 0 t)
#+END_SRC
-**** TODO Mode line
+**** Mode line
-#+NAME: mode-line-format
-#+BEGIN_SRC emacs-lisp :tangle no
- (setq mode-line-format
- (list mode-line-modified
- '(:eval
- (list
- " "
- (if buffer-read-only "🔒" "🔓")
- (propertize " %b "
- 'help-echo (buffer-file-name)
- )
- (if (buffer-modified-p) "🖉" "✓")
- ))))
+This interpretation of the ideal mode line is the result of
+carefully studying the default ~mode-line~, as well as studying
+various customizations online.
+
+#+BEGIN_SRC emacs-lisp :tangle yes
+ (setq-default mode-line-format
+ (list
+ mode-line-front-space
+ '(:eval (if buffer-read-only
+ (propertize "🔒" 'help-echo "C-x C-q: unlock buffer.")
+ (propertize "🔓" 'help-echo "C-x C-q: lock buffer.")))
+ '(:eval (if (buffer-modified-p)
+ (propertize " 🖉 " 'help-echo "Buffer is modified.")
+ (propertize " ✓ " 'help-echo "Buffer is saved.")))
+ mode-line-modes " "
+ mode-line-end-spaces))
#+END_SRC
** Window
Copyright 2019--2024 Marius PETER