Reorganize

This commit is contained in:
contrapunctus 2022-01-16 12:50:06 +05:30
parent dc738b849b
commit 73d9959a52
1 changed files with 112 additions and 110 deletions

222
init.org
View File

@ -199,7 +199,7 @@ NAME is the name of the process and its buffer."
("C-r" . volume-lower-10)))
#+END_SRC
* Emacs and Emacs-specific packages
* Emacs-wide settings and Emacs-specific packages
:PROPERTIES:
:CUSTOM_ID: emacs-settings
:END:
@ -219,12 +219,19 @@ NAME is the name of the process and its buffer."
ispell-dictionary "en"
scroll-conservatively 10000
scroll-preserve-screen-position t
auto-window-vscroll nil)
auto-window-vscroll nil
locale-coding-system 'utf-8
file-name-coding-system 'utf-8
buffer-file-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(setq-default undo-limit (* 80 1000))
(load custom-file))
#+END_SRC
** package
** package.el :package:
#+BEGIN_SRC emacs-lisp
(use-package package
:bind
@ -279,6 +286,38 @@ NAME is the name of the process and its buffer."
("<f1> v" . #'helpful-variable)))
#+END_SRC
** keyfreq :disabled:
#+BEGIN_SRC emacs-lisp
(use-package keyfreq
:disabled
:init
(keyfreq-mode 1)
(keyfreq-autosave-mode 1))
;; ;; disabled on 2017-08-18T19:39:21+0530, no longer interested
;; (open-dribble-file (concat "~/.emacs.d/keylogs/"
;; (format-time-string "%Y%m%d-%H%M%S")
;; ".txt"))
;; 2017-10-14T15:22:56+0530 - I suspect devanagari-itrans tires the
;; left hand faster than the right - let's find out!
;; ;; 2020-08-05T16:28:07+0530 commented out, no longer interested
;; (add-hook
;; 'input-method-activate-hook
;; (lambda ()
;; (open-dribble-file
;; (concat
;; "~/.emacs.d/keylogs/"
;; (format-time-string "%Y%m%d-%H%M%S")
;; "-"
;; current-input-method
;; ".txt"))))
;; (add-hook
;; 'input-method-deactivate-hook
;; (lambda () (open-dribble-file nil)))
#+END_SRC
* User interface
:PROPERTIES:
:CUSTOM_ID: ui
@ -303,6 +342,17 @@ NAME is the name of the process and its buffer."
(defalias 'yes-or-no-p 'y-or-n-p)
#+END_SRC
** time
:PROPERTIES:
:CREATED: 2022-01-16T12:47:09+0530
:END:
#+BEGIN_SRC emacs-lisp
(use-package time
:config
(setq display-time-next-load-average t)
(add-to-list 'zoneinfo-style-world-list '("Europe/Berlin" "Berlin")))
#+END_SRC
** shackle
:PROPERTIES:
:CUSTOM_ID: ui-shackle
@ -456,11 +506,33 @@ Must put this after loading the custom file, or I get prompted about the theme e
(use-package compile
:config
;; (add-hook 'compilation-start-hook
;; (lambda (proc)
;; (delete-other-windows)))
;; (lambda (proc) (delete-other-windows)))
(setq compilation-always-kill t))
#+END_SRC
*** my-compile-project
:PROPERTIES:
:CREATED: 2022-01-16T12:44:33+0530
:END:
#+BEGIN_SRC emacs-lisp
(defun my-compile-project (file &optional prefix cmd)
"Enter ancestor directory containing FILE and run compile command CMD.
If CMD is not supplied, use `compile-command'.
With PREFIX argument and omitted CMD, prompt for command."
(interactive "fDominating File: \nP")
(when-let ((dir (locate-dominating-file default-directory file)))
(cd dir))
(compile
(cond (prefix
(compilation-read-command
(or cmd "")))
(cmd cmd)
(t compile-command)))
;; (select-window (split-window-below))
;; (switch-to-buffer (compilation-find-buffer))
(boon-mode))
#+END_SRC
*** jump to Org LP from compilation output
:PROPERTIES:
:CUSTOM_ID: compile-org-lp-jump
@ -509,39 +581,7 @@ ARGS are ignored."
#+END_SRC
** keyfreq :disabled:
#+BEGIN_SRC emacs-lisp
(use-package keyfreq
:disabled
:init
(keyfreq-mode 1)
(keyfreq-autosave-mode 1))
;; ;; disabled on 2017-08-18T19:39:21+0530, no longer interested
;; (open-dribble-file (concat "~/.emacs.d/keylogs/"
;; (format-time-string "%Y%m%d-%H%M%S")
;; ".txt"))
;; 2017-10-14T15:22:56+0530 - I suspect devanagari-itrans tires the
;; left hand faster than the right - let's find out!
;; ;; 2020-08-05T16:28:07+0530 commented out, no longer interested
;; (add-hook
;; 'input-method-activate-hook
;; (lambda ()
;; (open-dribble-file
;; (concat
;; "~/.emacs.d/keylogs/"
;; (format-time-string "%Y%m%d-%H%M%S")
;; "-"
;; current-input-method
;; ".txt"))))
;; (add-hook
;; 'input-method-deactivate-hook
;; (lambda () (open-dribble-file nil)))
#+END_SRC
** TODO hydra [0%]
** TODO Hydra [0%]
I started off using Hydra for programming modes, when I noticed that Elisp, Common Lisp, and Scheme all had some semantically-analogous operations with different names, which could be abstracted away behind a generic interface. Then, around the time I got into using Org for literate programs, I added an Org hydra, and then a general hydra for frequently-used operations.
Add these common operations to the hydra -
@ -693,25 +733,6 @@ _u_: next word ^_l_: edit lines^ _s_: next whole symbol
#+END_SRC
*** General
#+BEGIN_SRC emacs-lisp
(defun my-compile-project (file &optional prefix cmd)
"Enter ancestor directory containing FILE and run compile command CMD.
If CMD is not supplied, use `compile-command'.
With PREFIX argument and omitted CMD, prompt for command."
(interactive "fDominating File: \nP")
(when-let ((dir (locate-dominating-file default-directory file)))
(cd dir))
(compile
(cond (prefix
(compilation-read-command
(or cmd "")))
(cmd cmd)
(t compile-command)))
;; (select-window (split-window-below))
;; (switch-to-buffer (compilation-find-buffer))
(boon-mode))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(my-defhydra contrapunctus-general-hydra (:color blue)
"What command?"
@ -1036,7 +1057,7 @@ Don't try to check if there are files with a certain extension...it will lead to
("b" org-babel-execute-src-block "source block"))
#+END_SRC
*** sql
*** SQL
#+BEGIN_SRC emacs-lisp
(defhydra my-sql-eval-hydra (:color blue)
"Eval"
@ -1280,6 +1301,17 @@ as links into an Org or Markdown document."
(define-key text-mode-map (kbd "M-n") 'org-drag-line-forward))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defun cp-insert-timestamp (&optional date-only-p)
"Insert current date and time in ISO-8601 format in the current buffer."
(interactive)
(let ((timestamp (format-time-string
(if date-only-p "%F" "%FT%T%z"))))
(cond ((derived-mode-p 'emacs-lisp-mode)
(insert "\"" timestamp "\""))
(t (insert timestamp)))))
#+END_SRC
** undo-tree
:PROPERTIES:
:CUSTOM_ID: editing-undo-tree
@ -3406,20 +3438,6 @@ But with =initials=, the desired completion is often buried in the results. That
"C-)" 'abort-recursive-edit)
#+END_SRC
* UTF-8 incantations
:PROPERTIES:
:CUSTOM_ID: UTF-8 incantations
:END:
#+BEGIN_SRC emacs-lisp
(setq locale-coding-system 'utf-8
file-name-coding-system 'utf-8
buffer-file-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
#+END_SRC
* Linewrapping
#+BEGIN_SRC emacs-lisp
(add-hook 'erc-mode-hook 'visual-line-mode)
@ -3624,42 +3642,6 @@ jumping to match from M-x grep , too)
(add-hook 'next-error-hook 'recenter)
#+END_SRC
* date and time
#+BEGIN_SRC emacs-lisp
(defun cp-insert-timestamp (&optional date-only-p)
"Insert current date and time in ISO-8601 format in the current buffer."
(interactive)
(let ((timestamp (format-time-string
(if date-only-p "%F" "%FT%T%z"))))
(cond ((derived-mode-p 'emacs-lisp-mode)
(insert "\"" timestamp "\""))
(t (insert timestamp)))))
(use-package time
:config
(setq display-time-next-load-average t)
(add-to-list 'zoneinfo-style-world-list '("Europe/Berlin" "Berlin")))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defun cp/eval-sexp (arg)
"In emacs-lisp-mode, just run eval-defun.
In other modes - jump to first Lisp expression in current line
and eval it."
(interactive "P")
(save-excursion
(cond ((or
(equal major-mode 'emacs-lisp-mode)
(equal major-mode 'lisp-interaction-mode))
(eval-defun arg))
((cp/re-search-line "(")
(progn
(forward-char -1)
(forward-sexp)
(eval-last-sexp arg)))
(t nil))))
#+END_SRC
* Buffer management
#+BEGIN_SRC emacs-lisp
(defun my-buffer-switch ()
@ -4651,8 +4633,28 @@ active, else `sp-copy-sexp'."
#+END_SRC
#+BEGIN_SRC emacs-lisp
;; (use-package elsa
;; :commands flycheck-elsa-setup)
(defun cp/eval-sexp (arg)
"In emacs-lisp-mode, just run eval-defun.
In other modes - jump to first Lisp expression in current line
and eval it."
(interactive "P")
(save-excursion
(cond ((or (equal major-mode 'emacs-lisp-mode)
(equal major-mode 'lisp-interaction-mode))
(eval-defun arg))
((cp/re-search-line "(")
(progn
(forward-char -1)
(forward-sexp)
(eval-last-sexp arg)))
(t nil))))
#+END_SRC
*** ELSA - Emacs Lisp Static Analyzer :disabled:
#+BEGIN_SRC emacs-lisp
(use-package elsa
:disabled t
:commands flycheck-elsa-setup)
#+END_SRC
*** literate-elisp