From 57841624b6c75ad87a146210b0952350fd8229fd Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 13 Jan 2021 20:19:56 -0600 Subject: Delete re-definition of lisp-indent-function for something simpler The compiler kept complaining about how the variable ‘calculate-lisp-indent-last-sexp’ was “free,” which is due to (according to [1]) the fact that it’s dynamically bound, as opposed to lexical – so it’s actually defined further up the function call-chain, meaning it works but the compiler complains about it. I didn’t like all the complaining, so I tried installing ‘el-patch’ per this StackOverflow discussion[2], thinking that a package built allegedly specifically for this purpose would fix the dynamic/lexical binding mess, but of course it didn’t. So I just went and applied the changes in abo-abo’s answer[3], which set the indent-functions for elisp to be the same as cl. C’est la vie. [1]: https://emacs.stackexchange.com/questions/52782/ [2]: https://stackoverflow.com/questions/22166895/ [3]: https://stackoverflow.com/a/22167050 --- README.md | 233 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- config.org | 93 +++--------------------- 2 files changed, 225 insertions(+), 101 deletions(-) diff --git a/README.md b/README.md index bde17e1..dc977c3 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ doesn't work, I'll call git directly and clone the repo myself. ### Emulate use-package’s `:custom` - (defmacro cuss (var val &optional docstring) + (defmacro cuss (var val &optional _docstring) "Basically, `:custom' from `use-package', but without `use-package'." (declare (doc-string 3) (indent 2)) @@ -407,7 +407,7 @@ helper function, though, to add things to the whitelist. (: (any ?a ?A ?p ?P) (any ?m ?M))) (* nonl))) (ss (sunrise-sunset)) - (m_ (string-match times-regex ss)) + (_m (string-match times-regex ss)) (sunrise-time (match-string 1 ss)) (sunset-time (match-string 2 ss))) (run-at-time sunrise-time (* 60 60 24) sunrise-command) @@ -640,6 +640,20 @@ from [u/TheFrenchPoulp](https://www.reddit.com/r/emacs/comments/km9by4/weekly_ti (apply original arguments))) +### Scroll much faster + +from [mpereira](https://github.com/mpereira/.emacs.d#make-cursor-movement-an-order-of-magnitude-faster), from somewhere else. + + (cuss auto-window-vscroll nil + "Don't auto-adjust `window-vscroll' to view long lines.") + + (cuss fast-but-imprecise-scrolling t + "Scroll fast, but possibly with inaccurate text rendering.") + + (cuss jit-lock-defer-time 0 + "Only defer font-locking when input is pending.") + + ## Persistence @@ -743,9 +757,7 @@ from [Mastering Emacs](https://www.masteringemacs.org/article/working-coding-sys (set-keyboard-coding-system 'utf-8) ;; backwards compatibility: ;; `default-buffer-file-coding-system' is deprecated in 23.2. - (if (boundp 'buffer-file-coding-system) - (setq-default buffer-file-coding-system 'utf-8) - (setq default-buffer-file-coding-system 'utf-8)) + (setq default-buffer-file-coding-system 'utf-8) ;; Treat clipboard as UTF-8 string first; compound text next, etc. (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)) @@ -830,7 +842,7 @@ Because I like *overkill*, or at least … over-*saving*. (straight-use-package 'sudo-edit) (with-eval-after-load 'sudo-edit - (global-set-key acdw/map (kbd "C-r") #'sudo-edit)) + (define-key acdw/map (kbd "C-r") #'sudo-edit)) #### Don’t add `/sudo:` files to `recentf`, though @@ -867,7 +879,14 @@ I’ve pretty much cribbed this from [recentf-remove-sudo-tramp-prefix](https:// ### View long lines like filled lines in the beginning (straight-use-package 'adaptive-wrap) - (adaptive-wrap-prefix-mode +1) + + (when (fboundp 'adaptive-wrap-prefix-mode) + (defun acdw/activate-adaptive-wrap-prefix-mode () + "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously." + (adaptive-wrap-prefix-mode (if visual-line-mode + +1 + -1))) + (add-hook 'visual-line-mode-hook #'acdw/activate-adaptive-wrap-prefix-mode)) ### Stay snappy with long-lined files @@ -1042,6 +1061,28 @@ I’ve pretty much cribbed this from [recentf-remove-sudo-tramp-prefix](https:// "Don't truncate printed expressions by level.") +#### Eros (Evaluation Result OverlayS) + + (straight-use-package 'eros) + + (cuss eros-eval-result-prefix ";; => " + "Prefix displayed before eros overlays.") + + (eros-mode +1) + + +#### Indent Elisp like Common Lisp + + (setq lisp-indent-function 'common-lisp-indent-function) + (put 'cl-flet 'common-lisp-indent-function + (get 'flet 'common-lisp-indent-function)) + (put 'cl-labels 'common-lisp-indent-function + (get 'labels 'common-lisp-indent-function)) + (put 'if 'common-lisp-indent-function 2) + (put 'dotimes-protect 'common-lisp-indent-function + (get 'when 'common-lisp-indent-function)) + + ### Janet (straight-use-package 'janet-mode) @@ -1151,19 +1192,44 @@ This has to be done *before* loading the package. It's included in `visual-fill # Applications +## Web browsing + + (cuss browse-url-browser-function 'browse-url-firefox) + (cuss browse-url-new-window-flag t + "Always open a new browser window.") + + ;;(cuss browse-url-generic-program "firefox") + (cuss browse-url-firefox-new-window-is-tab t + "Or a new tab, in Firefox.") + + ;; we need to add Firefox to `exec-path' on Windows + (at-work + (add-to-list 'exec-path "c:/Program Files/Mozilla Firefox")) + + ## Dired ### Basic customization + (defun acdw/setup-dired-mode () + (hl-line-mode) + (dired-hide-details-mode)) + ;; highlight the current line in dired. - (add-hook 'dired-mode-hook #'hl-line-mode) + (add-hook 'dired-mode-hook #'acdw/setup-dired-mode) (cuss dired-recursive-copies 'always "Always recursively copy.") + (cuss dired-recursive-deletes 'always + "Always recursively delete.") + + (cuss delete-by-moving-to-trash t) + (cuss dired-listing-switches "-alh" - "Show All items, Listed out, with Human-readable sizes.") + "Show (A)lmost all items, + (l)isted out, with (h)uman-readable sizes.") ### Expand subtrees @@ -1241,13 +1307,32 @@ I’ve put org mode under Applications, as opposed to Writing, because it’s m (variable-pitch)))))) +##### Align all tags in the buffer on changes + +from [mpereira](https://github.com/mpereira/.emacs.d#align-all-tags-in-the-buffer-on-tag-changes). + + (defun acdw/org-align-all-tags () + "Align all org tags in the buffer." + (interactive) + (when (eq major-mode 'org-mode) + (org-align-tags t))) + + (add-hook 'org-after-tags-change-hook #'acdw/org-align-all-tags) + + +#### Source blocks + + (set-face-attribute 'org-block-begin-line nil + :height 0.85) + + #### Prettify (defun acdw/org-mode-prettify () "Prettify `org-mode'." - (dolist (cell '(("[ ]" . ?□) ("[X]" . ?☑) ("[-]" . ?◐) - ("#+begin_src" . ?✎) ("#+begin_src" . ?✎) - ("#+end_src" . ?■) ("#+end_src" . ?■))) + (dolist (cell '(("[ ]" . ?☐) ("[X]" . ?☑) ("[-]" . ?◐) + ("#+BEGIN_SRC" . ?✎) ("#+begin_src" . ?✎) + ("#+END_SRC" . ?■) ("#+end_src" . ?■))) (add-to-list 'prettify-symbols-alist cell :append)) (prettify-symbols-mode +1)) @@ -1413,8 +1498,9 @@ from [unpackaged.el](https://github.com/alphapapa/unpackaged.el#ensure-blank-lin ### Org Templates (`org-tempo`) - (add-to-list 'org-structure-template-alist - '("el" . "src emacs-lisp")) + (with-eval-after-load 'org + (add-to-list 'org-structure-template-alist + '("el" . "src emacs-lisp"))) ### Org Agenda @@ -1429,6 +1515,9 @@ from [unpackaged.el](https://github.com/alphapapa/unpackaged.el#ensure-blank-lin (define-key acdw/map (kbd "C-a") #'org-agenda) + (cuss org-agenda-span 5 + "Show today + N days.") + (cuss org-todo-keywords '((sequence "RECUR(r)" "TODO(t)" "|" "DONE(d)") (sequence "APPT(a)") @@ -1438,9 +1527,100 @@ from [unpackaged.el](https://github.com/alphapapa/unpackaged.el#ensure-blank-lin (cuss org-agenda-skip-deadline-if-done t) (cuss org-deadline-warning-days 0 "Don't warn of an impending deadline.") - - -### TODO Capture + + (cuss org-log-into-drawer "LOGBOOK" + "Log state changes into the LOGBOOK drawer, instead of after + the headline.") + (cuss org-log-done t + "Save CLOSED timestamp when done.") + + +### Capture + + +#### Templates + + (cuss org-default-notes-file (expand-file-name "inbox.org" + org-directory) + "Put unfiled notes in ~/Org/inbox.org.") + + + (cuss org-capture-templates + '(("w" "Work Todo") ;;; Work stuff + ("ws" "Small Business" entry + (file+headline "work.org" "Small Business") + "* TODO %? + :PROPERTIES: + :Via: + :Note: + :END: + :LOGBOOK: + - State \"TODO\" from \"\" %U + :END:" :empty-lines 1) + ("wc" "Career Center" entry + (file+headline "work.org" "Career Center") + "* TODO %? + :PROPERTIES: + :Via: + :Note: + :END: + :LOGBOOK: + - State \"TODO\" from \"\" %U + :END:" :empty-lines 1) + ("wg" "General" entry + (file+headline "work.org" "General") + "* TODO %? + :PROPERTIES: + :Via: + :Note: + :END: + :LOGBOOK: + - State \"TODO\" from \"\" %U + :END:" :empty-lines 1) + + ;;; Regular To-Dos + ("t" "Todo") + ("tt" "Todo" entry + (file+headline "home.org" "TODOs") + "* TODO %? + :PROPERTIES: + :Via: + :Note: + :END: + :LOGBOOK: + - State \"TODO\" from \"\" %U + :END:" :empty-lines 1) + + ("td" "Todo with deadline" entry + (file+headline "home.org" "TODOs") + "* TODO %? + DEADLINE: %^t + :PROPERTIES: + :Via: + :Note: + :END: + :LOGBOOK: + - State \"TODO\" from \"\" %U + :END:" :empty-lines 1) + + + ("g" "Gift idea" entry + (file+headline "home.org" "Gift ideas") + "* %^{Who?} + * %^{What?}" :empty-lines 1) + + ("d" "Diary entry" entry + (file+datetree "diary.org") + "* %? + Entered on %U + + " :empty-lines 1))) + + +#### Keybindings + + (with-eval-after-load 'org-capture + (define-key acdw/map (kbd "C-c") #'org-capture)) ### Include Org links in source code @@ -1742,9 +1922,19 @@ I’m only enabling this at home for now, since it requires building stuff. (list "ttrss+https://acdw@rss.tildeverse.org" :use-authinfo t))) - (setq elfeed-log-level 'debug) + ;; Uncomment this line if elfeed is giving problems. + ;; (setq elfeed-log-level 'debug) (elfeed-protocol-enable) + + (defun acdw/update-elfeed-protocol-feeds () + "Wrap various (non-working) protocol updaters. + I could probably do this in a much more ... better way." + (interactive) + (elfeed-protocol-ttrss-reinit "https://rss.tildeverse.org")) + + (with-eval-after-load 'elfeed + (define-key elfeed-search-mode-map "G" #'acdw/update-elfeed-protocol-feeds)) # System integration @@ -1816,7 +2006,7 @@ I’m only enabling this at home for now, since it requires building stuff. (interactive "P") (let ((config (expand-file-name "config.org" user-emacs-directory))) (save-mark-and-excursion - (with-current-buffer (find-file config) + (with-current-buffer (find-file-noselect config) (let ((prog-mode-hook nil)) ;; generate the readme (when (file-newer-than-file-p config (expand-file-name @@ -1918,3 +2108,8 @@ GPL, for what should be fairly obvious reasons. To that, I say: **SUE ME, RMS!** + +## TODO Local variables + +One day, I’m going to add a Local Variables block to the end of this file, which will add an `after-save-hook` to auto-tangle the file after saving. But first I need to research how best to do that asynchronously. So. + diff --git a/config.org b/config.org index d430220..949ef22 100644 --- a/config.org +++ b/config.org @@ -5,7 +5,7 @@ #+EXPORT_FILE_NAME: README.md #+OPTIONS: toc:nil #+BANKRUPTCY_COUNT: 3.2 -#+Time-stamp: <2021-01-13 17:27:55 aduckworth> +#+Time-stamp: <2021-01-13 20:19:13 acdw> * Basics @@ -1255,89 +1255,18 @@ from [[https://github.com/mpereira/.emacs.d#make-cursor-movement-an-order-of-mag (eros-mode +1) #+end_src -**** Fix plists in elisp - -from [[https://github.com/Fuco1/.emacs.d/blob/a8230343bb7e2f07f5eac8e63e5506fa164344f6/site-lisp/my-redef.el#L25][Fuco1]], via mpereira – it’s also in another config I looked at, but using =el-patch=, which I’m not ready to do quite yet. +**** Indent Elisp like Common Lisp #+begin_src emacs-lisp - - ;; redefines the silly indent of keyword lists - ;; before - ;; (:foo bar - ;; :baz qux) - ;; after - ;; (:foo bar - ;; :baz qux) - (eval-after-load "lisp-mode" - '(defun lisp-indent-function (indent-point state) - "This function is the normal value of the variable `lisp-indent-function'. - The function `calculate-lisp-indent' calls this to determine - if the arguments of a Lisp function call should be indented specially. - INDENT-POINT is the position at which the line being indented begins. - Point is located at the point to indent under (for default indentation); - STATE is the `parse-partial-sexp' state for that position. - If the current line is in a call to a Lisp function that has a non-nil - property `lisp-indent-function' (or the deprecated `lisp-indent-hook'), - it specifies how to indent. The property value can be: - ,* `defun', meaning indent `defun'-style - \(this is also the case if there is no property and the function - has a name that begins with \"def\", and three or more arguments); - ,* an integer N, meaning indent the first N arguments specially - (like ordinary function arguments), and then indent any further - arguments like a body; - ,* a function to call that returns the indentation (or nil). - `lisp-indent-function' calls this function with the same two arguments - that it itself received. - This function returns either the indentation to use, or nil if the - Lisp function does not specify a special indentation." - (let ((normal-indent (current-column)) - (orig-point (point))) - (goto-char (1+ (elt state 1))) - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) - (cond - ;; car of form doesn't seem to be a symbol, or is a keyword - ((and (elt state 2) - (or (not (looking-at "\\sw\\|\\s_")) - (looking-at ":"))) - (if (not (> (save-excursion (forward-line 1) (point)) - calculate-lisp-indent-last-sexp)) - (progn (goto-char calculate-lisp-indent-last-sexp) - (beginning-of-line) - (parse-partial-sexp (point) - calculate-lisp-indent-last-sexp 0 t))) - ;; Indent under the list or under the first sexp on the same - ;; line as calculate-lisp-indent-last-sexp. Note that first - ;; thing on that line has to be complete sexp since we are - ;; inside the innermost containing sexp. - (backward-prefix-chars) - (current-column)) - ((and (save-excursion - (goto-char indent-point) - (skip-syntax-forward " ") - (not (looking-at ":"))) - (save-excursion - (goto-char orig-point) - (looking-at ":"))) - (save-excursion - (goto-char (+ 2 (elt state 1))) - (current-column))) - (t - (let ((function (buffer-substring (point) - (progn (forward-sexp 1) (point)))) - method) - (setq method (or (function-get (intern-soft function) - 'lisp-indent-function) - (get (intern-soft function) 'lisp-indent-hook))) - (cond ((or (eq method 'defun) - (and (null method) - (> (length function) 3) - (string-match "\\`def" function))) - (lisp-indent-defform state indent-point)) - ((integerp method) - (lisp-indent-specform method state - indent-point normal-indent)) - (method - (funcall method indent-point state))))))))) + (require 'cl-lib) + (setq lisp-indent-function 'common-lisp-indent-function) + (put 'cl-flet 'common-lisp-indent-function + (get 'flet 'common-lisp-indent-function)) + (put 'cl-labels 'common-lisp-indent-function + (get 'labels 'common-lisp-indent-function)) + (put 'if 'common-lisp-indent-function 2) + (put 'dotimes-protect 'common-lisp-indent-function + (get 'when 'common-lisp-indent-function)) #+end_src *** Janet -- cgit 1.4.1-21-gabe81