diff --git a/ha-aux-apps.org b/ha-aux-apps.org index c283a86..d729e92 100644 --- a/ha-aux-apps.org +++ b/ha-aux-apps.org @@ -24,7 +24,112 @@ A literate programming file for helper apps in Emacs. #+END_SRC * Introduction The following applications are not really needed. I alternate between trying to /stay in Emacs/ taking advantage of the consistent interface, and simply using a stand-alone app on my Workday computer. -** Twitter +* Terminal +The following section configures my Terminal experience, both inside and outside Emacs. +** Eshell +I used to use [[http://www.howardism.org/Technical/Emacs/eshell.html][Eshell all the time]], but now I've migrated most of /work/ directly into Emacs (rewriting all those shell scripts a Emacs Lisp code). However, a shell is pretty good for my brain at organizing files (old habits, maybe). + +#+BEGIN_SRC emacs-lisp + (use-package eshell + :config (ha-leader "a e" '("eshell" . eshell-here))) +#+END_SRC + +I usually want a new window running Eshell, that is smaller than the current buffer: + +#+BEGIN_SRC emacs-lisp + (defun eshell-here () + "Opens up a new shell in the directory associated with the + current buffer's file. Rename the eshell buffer name to match + that directory to make multiple eshell windows easier." + (interactive) + (let* ((parent (if (buffer-file-name) + (file-name-directory (buffer-file-name)) + default-directory)) + (height (/ (window-total-height) 3)) + (name (car (last (split-string parent "/" t))))) + (split-window-vertically (- height)) + (eshell "new") + (rename-buffer (concat "*eshell: " name "*")) + + (insert (concat "ls")) + (eshell-send-input))) +#+END_SRC + +And since Emacs supplies Eshell, we can just define these helper functions: + +#+BEGIN_SRC emacs-lisp + (defun eshell/e (file) + (find-file file)) + + (defun eshell/ee (file) + (find-file-other-window file)) + + (defun eshell/x () + (insert "exit") + (eshell-send-input) + (delete-window)) +#+END_SRC + +Add my org-specific predicates, see this [[http://www.howardism.org/Technical/Emacs/eshell-fun.html][this essay]] for the details: +#+BEGIN_SRC emacs-lisp + (defun eshell-org-file-tags () + "Helps the eshell parse the text the point is currently on, + looking for parameters surrounded in single quotes. Returns a + function that takes a FILE and returns nil if the file given to + it doesn't contain the org-mode #+FILETAGS: entry specified." + + ;; Step 1. Parse the eshell buffer for our tag between quotes + ;; Make sure to move point to the end of the match: + (if (looking-at "'\\([^)']+\\)'") + (let* ((tag (match-string 1)) + (reg (rx bol "#+FILETAGS: " + (zero-or-more any) + word-start + (literal tag) + word-end + (zero-or-more any) + eol))) + (goto-char (match-end 0)) + + ;; Step 2. Return the predicate function: + ;; Careful when accessing the `reg' variable. + `(lambda (file) + (with-temp-buffer + (insert-file-contents file) + (re-search-forward ,reg nil t 1)))) + (error "The `T' predicate takes an org-mode tag value in single quotes."))) + + (add-to-list 'eshell-predicate-alist '(?T . (eshell-org-file-tags))) +#+END_SRC +** VTerm + +I'm not giving up on Eshell, but I am playing around with [[https://github.com/akermu/emacs-libvterm][vterm]], and it is pretty good, but I use it primarily as a more reliable approach to [[file:ha-remoting.org][a remote shell]]. + +VTerm has an issue (at least for me) with ~M-Backspace~ not deleting the previous word, and yeah, I want to make sure that both keystrokes do the same thing. + +#+BEGIN_SRC emacs-lisp :tangle no +(use-package vterm + :init + (setq vterm-shell "/usr/local/bin/fish") + ;; Granted, I seldom pop out to the shell except during code demonstrations, + ;; but I like how C-p/C-n jumps up to each prompt entry using this setting + ;; that works with my prompt: + (setq vterm-use-vterm-prompt-detection-method nil + term-prompt-regexp "^.* $ ") + :config + (dolist (k '("" "")) + (define-key vterm-mode-map (kbd k) + (lambda () (interactive) (vterm-send-key (kbd "C-w"))))) + + (advice-add 'vterm-copy-mode :after 'evil-normal-state)) +#+END_SRC + +The advantage of running terminals in Emacs is the ability to copy text without a mouse. For that, hit ~C-c C-t~ to enter a special copy-mode. If I go into this mode, I might as well also go into normal mode to move the cursor. + +*Note:* To exit the copy-mode (and copy the selected text to the clipboard), hit ~Return~. + +Hrm. Seems that I might want a function to copy the output of the last command to a register, or even an org-capture... +* Twitter The venerable [[https://github.com/hayamiz/twittering-mode/tree/master][twittering-mode]] allows me to follow all the twits. #+BEGIN_SRC emacs-lisp (use-package twittering-mode @@ -34,7 +139,7 @@ The venerable [[https://github.com/hayamiz/twittering-mode/tree/master][twitteri :config (defalias 'epa--decode-coding-string 'decode-coding-string)) #+END_SRC -** Telega +* Telega I'm thinking the [[https://zevlg.github.io/telega.el/][Telega package]] would be better than Bitlbee for Telegram communication. #+BEGIN_SRC emacs-lisp :tangle no @@ -45,6 +150,34 @@ I'm thinking the [[https://zevlg.github.io/telega.el/][Telega package]] would be For some reason, you need [[https://github.com/Fanael/rainbow-identifiers][rainbow-identifiers]] to work, oh, I guess the docs state this. *Note:* Turning this off as it needs version 1.7.7 of =tdlib=, and that isn't easily available on my Mac. Maybe I may enable this on my Linux system. +* Demo It +Making demonstrations /within/ Emacs with [[https://github.com/howardabrams/demo-it][demo-it]]. +#+BEGIN_SRC emacs-lisp + (use-package demo-it + :straight (:type git :protocol ssh :host github :repo "howardabrams/demo-it") + :commands (demo-it-create demo-it-start)) +#+END_SRC +Perhaps I should change the reference to this for more local development: +#+begin_example + :straight (:local-repo "~/other/demo-it") +#+end_example +** RPG DM +Been working on a project for getting Emacs helping as a /Dungeon Master's Assistant/, and I must say, it is coming along nicely. In case you are reading this, let me know, and I'll start to share it. + +#+BEGIN_SRC emacs-lisp + (use-package rpgdm + :straight (:local-repo "~/other/rpgdm") + :commands (rpgdm-mode rpgdm-tables-load) + :config (ha-leader "t D" '("rpg dm" . rpgdm-mode))) +#+END_SRC + +While it is a minor mode, I don't necessarily want to turn it on for all files. +Instead, in an Org file, I just need to include something like this: +#+BEGIN_SRC org +# Local Variables: +# eval: (progn (rpgdm-mode 1) (rpgdm-tables-load "ironsworn")) +# End: +#+END_SRC * Technical Artifacts :noexport: Let's =provide= a name so we can =require= this file: diff --git a/ha-config.org b/ha-config.org index bb86e6d..80a6191 100644 --- a/ha-config.org +++ b/ha-config.org @@ -161,13 +161,6 @@ For this, I use the =request= package, which is /asynchronous/ #+BEGIN_SRC emacs-lisp #+END_SRC -** Demo It -Making demonstrations /within/ Emacs with [[https://github.com/howardabrams/demo-it][demo-it]]. -#+BEGIN_SRC emacs-lisp - (use-package demo-it - :straight (:type git :protocol ssh :host github :repo "howardabrams/demo-it") - :commands (demo-it-create demo-it-start)) -#+END_SRC * Configuration Changes ** Initial Settings and UI Let's turn off the menu and other things: @@ -670,6 +663,7 @@ Ways to search for information goes under the ~s~ key. This primarily depends on "s j" '("next results" . ha-rg-go-next-results) "s k" '("prev results" . ha-rg-go-previous-results) "s b" '("results buffer" . ha-rg-go-results-buffer)) + (rg-enable-default-bindings (kbd "M-R")) (defun ha-rg-close-results-buffer () "Close to the `*rg*' buffer that `rg' creates." @@ -967,9 +961,7 @@ Granted, this list is essentially a list of projects that I'm currently developi '(("projects" "~/projects" ("breathe.org" "tasks.org")) ("personal" "~/personal" ("general.org")) ("technical" "~/technical" ("ansible.org")) - ("hamacs" "~/other/hamacs" ("README.org" "ha-config.org")) - ("rpg" "~/Dropbox/org/rpg" ("workdavians-dragon-heist.org" "dragon-heist.org")) - ("dm-work" "~/Dropbox/org/rpg-dm" ("README-mythic.org" "rpgdm.el"))) + ("hamacs" "~/other/hamacs" ("README.org" "ha-config.org"))) "List of default projects with a name.") #+END_SRC @@ -1201,40 +1193,13 @@ Web pages look pretty good with EWW, but I'm having difficulty getting it to ren (define-key eww-buffers-mode-map (kbd "q") #'eww-bookmark-kill) (define-key eww-bookmark-mode-map (kbd "q") #'eww-bookmark-kill)) #+END_SRC + And let's get [[https://github.com/abo-abo/ace-link][ace-link]] to work with EWW and Info pages: #+BEGIN_SRC emacs-lisp (use-package ace-link :config (ace-link-setup-default)) #+END_SRC -** VTerm - -I'm not giving up on Eshell, but I am playing around with [[https://github.com/akermu/emacs-libvterm][vterm]], and it is pretty good, but I use it primarily as a more reliable approach to [[file:ha-remoting.org][a remote shell]]. - -VTerm has an issue (at least for me) with ~M-Backspace~ not deleting the previous word, and yeah, I want to make sure that both keystrokes do the same thing. - -#+BEGIN_SRC emacs-lisp :tangle no -(use-package vterm - :init - (setq vterm-shell "/usr/local/bin/fish") - ;; Granted, I seldom pop out to the shell except during code demonstrations, - ;; but I like how C-p/C-n jumps up to each prompt entry using this setting - ;; that works with my prompt: - (setq vterm-use-vterm-prompt-detection-method nil - term-prompt-regexp "^.* $ ") - :config - (dolist (k '("" "")) - (define-key vterm-mode-map (kbd k) - (lambda () (interactive) (vterm-send-key (kbd "C-w"))))) - - (advice-add 'vterm-copy-mode :after 'evil-normal-state)) -#+END_SRC - -The advantage of running terminals in Emacs is the ability to copy text without a mouse. For that, hit ~C-c C-t~ to enter a special copy-mode. If I go into this mode, I might as well also go into normal mode to move the cursor. - -*Note:* To exit the copy-mode (and copy the selected text to the clipboard), hit ~Return~. - -Hrm. Seems that I might want a function to copy the output of the last command to a register, or even an org-capture... ** Neotree I primarily use [[https://github.com/jaypei/emacs-neotree][Neotree]] when I am screen-sharing my Emacs session with collegues as it shows a /project/ like an IDE. #+BEGIN_SRC emacs-lisp diff --git a/ha-programming.org b/ha-programming.org index bd670e1..59db60e 100644 --- a/ha-programming.org +++ b/ha-programming.org @@ -130,7 +130,7 @@ As I've mentioned [[http://www.howardism.org/Technical/Emacs/beep-for-emacs.html #+END_SRC While that code /advices/ the publishing and compile commands, I may want to add more. ** iEdit -While there are language-specific ways to rename variables and functions, =iedit= is often sufficient. +While there are language-specific ways to rename variables and functions, [[https://github.com/victorhge/iedit][iedit]] is often sufficient. #+BEGIN_SRC emacs-lisp (ha-leader "s e" '("iedit" . iedit-mode)) #+END_SRC