major refactor
- add my/ prefix to mini functions used by setup/tuning - add/refactor functions used directly to have kmn/ prefix - break generic functions that are re-used globally to dedicted elisp file - break workspace defintions out into dedicated elisp file
This commit is contained in:
parent
5ba85bbb76
commit
2b6e9edc6d
|
@ -54,6 +54,9 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; global config
|
||||
(load "~/.emacs.d.profiles/common/_global.el")
|
||||
(load "~/.emacs.d.profiles/common/generic_functions.el")
|
||||
(load "~/.emacs.d.profiles/common/workspaces.el")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; compile bytecode for this profile
|
||||
(unless (was-compiled-p "~/.emacs.d.profiles/code")
|
||||
|
|
|
@ -17,26 +17,6 @@
|
|||
(setq kmn/is-termux
|
||||
(string-suffix-p "Android" (string-trim (shell-command-to-string "uname -a"))))
|
||||
|
||||
(defun kmn/dired-default-directory-on-left ()
|
||||
(defvar parameters
|
||||
'(window-parameters . ((no-other-window . t)
|
||||
(no-delete-other-windows . t))))
|
||||
|
||||
(setq fit-window-to-buffer-horizontally t)
|
||||
(setq window-resize-pixelwise t)
|
||||
|
||||
"Display `default-directory' in side window on left, hiding details."
|
||||
(interactive)
|
||||
(let ((buffer (dired-noselect default-directory)))
|
||||
(with-current-buffer buffer (dired-hide-details-mode t))
|
||||
(display-buffer-in-side-window
|
||||
buffer `((side . left) (slot . -1)
|
||||
(window-width . fit-window-to-buffer)
|
||||
(preserve-size . (t . nil)) , parameters)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; ensure elisp plugins are compiled
|
||||
(require 'dash)
|
||||
(require 'f)
|
||||
|
@ -93,7 +73,7 @@
|
|||
|
||||
; open dirs in same dired window + open files in main window
|
||||
; facilitates static file browser sidebar
|
||||
(defun kemonine/dired-open()
|
||||
(defun my/dired-open()
|
||||
(interactive)
|
||||
(setq file (dired-get-file-for-visit))
|
||||
(if (equal (file-directory-p file) t)
|
||||
|
@ -106,23 +86,23 @@
|
|||
)
|
||||
)
|
||||
|
||||
(defun my-dired-init ()
|
||||
(defun my/dired-init ()
|
||||
"Bunch of stuff to run for dired, either immediately or when it's
|
||||
loaded."
|
||||
;; <add other stuff here>
|
||||
(define-key dired-mode-map [remap dired-find-file]
|
||||
'kemonine/dired-open)
|
||||
'my/dired-open)
|
||||
(define-key dired-mode-map [remap dired-mouse-find-file-other-window]
|
||||
'kemonine/dired-open)
|
||||
'my/dired-open)
|
||||
(define-key dired-mode-map [remap dired-up-directory]
|
||||
'dired-single-up-directory))
|
||||
|
||||
;; if dired's already loaded, then the keymap will be bound
|
||||
(if (boundp 'dired-mode-map)
|
||||
;; we're good to go; just add our bindings
|
||||
(my-dired-init)
|
||||
(my/dired-init)
|
||||
;; it's not loaded yet, so add our bindings to the load-hook
|
||||
(add-hook 'dired-load-hook 'my-dired-init))
|
||||
(add-hook 'dired-load-hook 'my/dired-init))
|
||||
|
||||
; icons / colors / line tunes
|
||||
(add-hook 'dired-mode-hook
|
||||
|
@ -190,34 +170,6 @@
|
|||
("j" . origami-forward-fold)
|
||||
("x" . origami-reset)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; modern home/end via C-a and C-e
|
||||
(defun kmn/my--smart-beginning-of-line ()
|
||||
"Move point to `beginning-of-line'. If repeat command it cycle
|
||||
position between `back-to-indentation' and `beginning-of-line'."
|
||||
(interactive "^")
|
||||
(if (eq last-command 'my--smart-beginning-of-line)
|
||||
(if (= (line-beginning-position) (point))
|
||||
(back-to-indentation)
|
||||
(beginning-of-line))
|
||||
(back-to-indentation)))
|
||||
|
||||
(defun kmn/my--smart-end-of-line ()
|
||||
"Move point to `end-of-line'. If repeat command it cycle
|
||||
position between last non-whitespace and `end-of-line'."
|
||||
(interactive "^")
|
||||
(if (and (eq last-command 'kmn/my--smart-end-of-line)
|
||||
(= (line-end-position) (point)))
|
||||
(skip-syntax-backward " " (line-beginning-position))
|
||||
(end-of-line)))
|
||||
|
||||
(defun kill-other-buffers ()
|
||||
"Kill all buffers but the current one. Don't mess with special buffers."
|
||||
(interactive)
|
||||
(dolist (buffer (buffer-list))
|
||||
(unless (or (eql buffer (current-buffer)) (not (buffer-file-name buffer)))
|
||||
(kill-buffer buffer))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Setup global keys
|
||||
(cua-mode 1)
|
||||
|
@ -252,19 +204,6 @@ position between last non-whitespace and `end-of-line'."
|
|||
(global-set-key (kbd "M-h") 'describe-bindings)
|
||||
(global-set-key (kbd "C-c C-d") #'helpful-at-point)
|
||||
|
||||
; more vscode/gui styled find/replace
|
||||
(defun query-replace-region-or-from-top ()
|
||||
"If marked, query-replace for the region, else for the whole buffer (start from the top)"
|
||||
(interactive)
|
||||
(progn
|
||||
(let ((orig-point (point)))
|
||||
(if (use-region-p)
|
||||
(call-interactively 'query-replace)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(call-interactively 'query-replace)))
|
||||
(message "Back to old point.")
|
||||
(goto-char orig-point))))
|
||||
(bind-key* "M-%" 'query-replace-region-or-from-top)
|
||||
(global-set-key (kbd "C-h") 'query-replace-region-or-from-top)
|
||||
|
||||
|
@ -510,22 +449,6 @@ position between last non-whitespace and `end-of-line'."
|
|||
'(zoom-ignored-major-modes '(dired-mode))
|
||||
'(temp-buffer-resize-mode t))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; quick reference notes as a pop up window
|
||||
(defun kmn/popwin-quick-ref ()
|
||||
(interactive)
|
||||
(when (eq system-type 'windows-nt)
|
||||
(popwin:find-file "~/org/_quick_reference.org"))
|
||||
(when kmn/is-termux
|
||||
(popwin:find-file "~/storage/shared/org/_quick_reference.org")))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; scratch buffer as a pop up window
|
||||
(defun kmn/popwin-scratch ()
|
||||
(interactive)
|
||||
(popwin:display-buffer "*scratch*")
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; popup windows
|
||||
(use-package popwin
|
||||
|
|
102
common/generic_functions.el
Normal file
102
common/generic_functions.el
Normal file
|
@ -0,0 +1,102 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; generic functions
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; open org agenda in top side window
|
||||
(defun kmn/org-agenda-on-top ()
|
||||
(defvar parameters
|
||||
'(window-parameters . ((no-other-window . t)
|
||||
(no-delete-other-windows . t))))
|
||||
|
||||
(setq fit-window-to-buffer-horizontally t)
|
||||
(setq window-resize-pixelwise t)
|
||||
|
||||
(interactive)
|
||||
(display-buffer-in-side-window
|
||||
(get-buffer "*Org Agenda*") `((side . top) (slot . 0)
|
||||
(window-width . fit-window-to-buffer)
|
||||
(preserve-size . (t . nil)) , parameters))
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; open dired with default directory in left side window
|
||||
(defun kmn/dired-default-directory-on-left ()
|
||||
(defvar parameters
|
||||
'(window-parameters . ((no-other-window . t)
|
||||
(no-delete-other-windows . t))))
|
||||
|
||||
(setq fit-window-to-buffer-horizontally t)
|
||||
(setq window-resize-pixelwise t)
|
||||
|
||||
"Display `default-directory' in side window on left, hiding details."
|
||||
(interactive)
|
||||
(let ((buffer (dired-noselect default-directory)))
|
||||
(with-current-buffer buffer (dired-hide-details-mode t))
|
||||
(display-buffer-in-side-window
|
||||
buffer `((side . left) (slot . -1)
|
||||
(window-width . fit-window-to-buffer)
|
||||
(preserve-size . (t . nil)) , parameters)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; quick reference notes as a pop up window
|
||||
(defun kmn/popwin-quick-ref ()
|
||||
(interactive)
|
||||
(when (eq system-type 'windows-nt)
|
||||
(popwin:find-file "~/org/_quick_reference.org"))
|
||||
(when kmn/is-termux
|
||||
(popwin:find-file "~/storage/shared/org/_quick_reference.org")))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; scratch buffer as a pop up window
|
||||
(defun kmn/popwin-scratch ()
|
||||
(interactive)
|
||||
(popwin:display-buffer "*scratch*")
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; modern home/end via C-a and C-e
|
||||
(defun kmn/smart-beginning-of-line ()
|
||||
"Move point to `beginning-of-line'. If repeat command it cycle
|
||||
position between `back-to-indentation' and `beginning-of-line'."
|
||||
(interactive "^")
|
||||
(if (eq last-command 'my--smart-beginning-of-line)
|
||||
(if (= (line-beginning-position) (point))
|
||||
(back-to-indentation)
|
||||
(beginning-of-line))
|
||||
(back-to-indentation)))
|
||||
|
||||
(defun kmn/smart-end-of-line ()
|
||||
"Move point to `end-of-line'. If repeat command it cycle
|
||||
position between last non-whitespace and `end-of-line'."
|
||||
(interactive "^")
|
||||
(if (and (eq last-command 'kmn/my--smart-end-of-line)
|
||||
(= (line-end-position) (point)))
|
||||
(skip-syntax-backward " " (line-beginning-position))
|
||||
(end-of-line)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; function to kill all non special, non active buffers
|
||||
(defun kmn/kill-other-buffers ()
|
||||
"Kill all buffers but the current one. Don't mess with special buffers."
|
||||
(interactive)
|
||||
(dolist (buffer (buffer-list))
|
||||
(unless (or (eql buffer (current-buffer)) (not (buffer-file-name buffer)))
|
||||
(kill-buffer buffer))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; find/replace all (interactive)
|
||||
(defun kmn/query-replace-region-or-from-top ()
|
||||
"If marked, query-replace for the region, else for the whole buffer (start from the top)"
|
||||
(interactive)
|
||||
(progn
|
||||
(let ((orig-point (point)))
|
||||
(if (use-region-p)
|
||||
(call-interactively 'query-replace)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(call-interactively 'query-replace)))
|
||||
(message "Back to old point.")
|
||||
(goto-char orig-point))))
|
21
common/workspaces.el
Normal file
21
common/workspaces.el
Normal file
|
@ -0,0 +1,21 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; various workspaces used day to day
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; org-mode workspace
|
||||
(defun kmn/workspace-org ()
|
||||
(interactive)
|
||||
; front load org-agenda so it doesnt reshuffle the frame layout on us
|
||||
(org-agenda nil "r")
|
||||
; start with fresh frame
|
||||
(delete-other-windows)
|
||||
; show kmn's slipbox
|
||||
(find-file "~/org/orgzly/_slipbox.org")
|
||||
; split window for additional file to show
|
||||
(split-window-below)
|
||||
(next-multiframe-window)
|
||||
; show kmn health notes/data tracker
|
||||
(find-file "~/org/health/health_mike.org")
|
||||
; put agenda in top side window (works around org-mode limitations
|
||||
(kmn/org-agenda-on-top)
|
||||
)
|
|
@ -1,6 +1,6 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; helper for building agenda file lists
|
||||
(defun load-org-agenda-files-recursively (dir) "Find all directories in DIR."
|
||||
(defun my/load-org-agenda-files-recursively (dir) "Find all directories in DIR."
|
||||
(unless (file-directory-p dir) (error "Not a directory `%s'" dir))
|
||||
(unless (equal (directory-files dir nil org-agenda-file-regexp t) nil)
|
||||
(add-to-list 'org-agenda-files dir)
|
||||
|
@ -21,7 +21,7 @@
|
|||
; this assumes youre operating on daily habits
|
||||
; https://emacs.stackexchange.com/questions/9433/how-to-make-org-prompt-for-a-timestamp-when-changing-state-of-a-todo/63809
|
||||
; https://stackoverflow.com/questions/25437069/how-can-i-mark-org-habits-as-done-in-the-past
|
||||
(defun kmn/org-habit-with-date (&optional arg)
|
||||
(defun my/org-habit-with-date (&optional arg)
|
||||
(interactive "P")
|
||||
(setq my-activation-time (current-time))
|
||||
(cl-letf* ((org-read-date-prefer-future nil)
|
||||
|
@ -64,7 +64,7 @@
|
|||
;; add new option to update habit for yesterday and reschedule it as active today
|
||||
(add-hook 'org-agenda-mode-hook
|
||||
(lambda ()
|
||||
(local-set-key (kbd "y") 'kmn/org-habit-with-date)))
|
||||
(local-set-key (kbd "y") 'my/org-habit-with-date)))
|
||||
(setq org-agenda-use-time-grid nil)
|
||||
(setq org-agenda-window-setup "current-window")
|
||||
|
||||
|
|
|
@ -2,21 +2,17 @@
|
|||
; inspiration for conditional capture template : https://storax.github.io/blog/2016/05/02/org-capture-tricks/
|
||||
|
||||
; helper functions
|
||||
(defvar oc-capture-prmt-history nil
|
||||
(defvar my-capture-prmt-history nil
|
||||
"History of prompt answers for org capture.")
|
||||
(defun oc/prmt (prompt variable)
|
||||
(defun my/prmt (prompt variable)
|
||||
"PROMPT for string, save it to VARIABLE and insert it."
|
||||
(make-local-variable variable)
|
||||
(set variable (read-string (concat prompt ": ") nil oc-capture-prmt-history)))
|
||||
(defun oc/inc (what text &rest fmtvars)
|
||||
(set variable (read-string (concat prompt ": ") nil my-capture-prmt-history)))
|
||||
(defun my/inc (what text &rest fmtvars)
|
||||
"Ask user to include WHAT. If user agrees return TEXT."
|
||||
(when (y-or-n-p (concat "Include " what "?"))
|
||||
(apply 'format text fmtvars)))
|
||||
(defun oc/inc (what text &rest fmtvars)
|
||||
"Ask user to include WHAT. If user agrees return TEXT."
|
||||
(when (y-or-n-p (concat "Include " what "?"))
|
||||
(apply 'format text fmtvars)))
|
||||
(defun oc/inc_date (what prefix)
|
||||
(defun my/inc_date (what prefix)
|
||||
"Ask user to include a date. If user agrees prompt for date."
|
||||
(when (y-or-n-p (concat "Include " what "?"))
|
||||
(concat prefix (org-time-stamp nil))))
|
||||
|
|
|
@ -1,41 +1,11 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; DESKTOP
|
||||
;; misc desktop specific overrides
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; misc desktop specific overrides
|
||||
; set more reasonable org habit line width
|
||||
(setq org-habit-graph-column 75)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Personal startup screen (Desktop)
|
||||
; - preferred org agenda as dedicated window at the top of the frame, n lines high
|
||||
; - common org files open in the bottom window
|
||||
(defun kmn/org-agenda-on-top ()
|
||||
(defvar parameters
|
||||
'(window-parameters . ((no-other-window . t)
|
||||
(no-delete-other-windows . t))))
|
||||
|
||||
(setq fit-window-to-buffer-horizontally t)
|
||||
(setq window-resize-pixelwise t)
|
||||
|
||||
(interactive)
|
||||
(display-buffer-in-side-window
|
||||
(get-buffer "*Org Agenda*") `((side . top) (slot . 0)
|
||||
(window-width . fit-window-to-buffer)
|
||||
(preserve-size . (t . nil)) , parameters))
|
||||
)
|
||||
|
||||
; set ui to standard org-workspace at launch
|
||||
(add-hook 'after-init-hook (lambda ()
|
||||
(interactive)
|
||||
; front load org-agenda so it doesnt reshuffle the frame layout on us
|
||||
(org-agenda nil "r")
|
||||
; start with fresh frame
|
||||
(delete-other-windows)
|
||||
; show kmn's slipbox
|
||||
(find-file "~/org/orgzly/_slipbox.org")
|
||||
; split window for additional file to show
|
||||
(split-window-below)
|
||||
(next-multiframe-window)
|
||||
; show kmn health notes/data tracker
|
||||
(find-file "~/org/health/health_mike.org")
|
||||
; put agenda in top side window (works around org-mode limitations
|
||||
(kmn/org-agenda-on-top)
|
||||
(kmn/workspace-org)
|
||||
))
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
(setq inhibit-switch-frame nil)
|
||||
(setq split-height-threshold 200)
|
||||
(setq split-width-threshold 200)
|
||||
(defun my-display-buffer-function (buf not-this-window)
|
||||
(defun my/display-buffer-function (buf not-this-window)
|
||||
(if (and (not pop-up-frames)
|
||||
(one-window-p)
|
||||
(or not-this-window
|
||||
|
@ -35,5 +35,5 @@
|
|||
(pop-up-windows nil))
|
||||
(display-buffer buf not-this-window)))
|
||||
|
||||
(setq display-buffer-function 'my-display-buffer-function)
|
||||
(setq display-buffer-function 'my/display-buffer-function)
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
|
@ -54,6 +54,9 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; global config
|
||||
(load "~/.emacs.d.profiles/common/_global.el")
|
||||
(load "~/.emacs.d.profiles/common/generic_functions.el")
|
||||
(load "~/.emacs.d.profiles/common/workspaces.el")
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; compile bytecode for this profile
|
||||
(unless (was-compiled-p "~/.emacs.d.profiles/org")
|
||||
|
|
Reference in a new issue