README files are literal configs

master
Pete Ley 3 years ago
parent 89c84e974d
commit 9b627b455f

@ -0,0 +1,3 @@
Welcome to my user config files! These are managed with symlinks
installed by [[https://www.gnu.org/software/stow/][GNU Stow]]. Check the individual modules for their literate
README.org files.

@ -1,5 +1,5 @@
export PATH=$HOME/bin:$PATH
for f in $HOME/.bashrc.d/*; do
source $f;
done
alias ls="ls --color=auto"
alias ll="ls -lh --color=auto -X"
alias tree="tree -a -I .git"

@ -1,2 +0,0 @@
alias ls="ls --color=auto"
alias ll="ls -lh --color=auto -X"

@ -0,0 +1,21 @@
* .bashrc setup
Add local bin file to path:
#+begin_src bash :tangle .bashrc
export PATH=$HOME/bin:$PATH
#+end_src
General aliases:
#+begin_src bash :tangle .bashrc
alias ls="ls --color=auto"
alias ll="ls -lh --color=auto -X"
alias tree="tree -a -I .git"
#+end_src
** Rename picture with date
How to rename a bunch of pictures in a directory using ImageMagick:
#+begin_src bash
#!/bin/sh
for f in $@; do
mv "$f" $( identify -verbose "$f" | grep Timestamp | sed 's/[ \t]*dng:Timestamp: //' | xargs -0 date +%F-%T.png -d )
done
#+end_src

@ -1,7 +0,0 @@
#!/bin/sh
# "rename pic with date"
for f in $@; do
mv "$f" $( identify -verbose "$f" | grep Timestamp | sed 's/[ \t]*dng:Timestamp: //' | xargs -0 date +%F-%T.png -d )
done

@ -10,4 +10,4 @@ Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=on-failure
[Install]
WantedBy=default.target
WantedBy=default.target

@ -1,86 +0,0 @@
#+BEGIN_SRC elisp :tangle init.el
#+END_SRC
* Packages
#+BEGIN_SRC elisp :tangle init.el
(require 'package)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(package-refresh-contents)
(setq package-selected-packages
'(helm
org-plus-contrib
org-roam
org-roam-bibtex
format-all
magit))
(package-install-selected-packages)
#+END_SRC
* Basic setup
#+BEGIN_SRC elisp :tangle init.el
(tool-bar-mode -1)
(scroll-bar-mode -1)
(menu-bar-mode -1)
(column-number-mode)
(setq inhibit-splash-screen t
backup-directory-alist '(("." . "~/.emacs.d/autosave")))
(load-theme 'misterioso)
#+END_SRC
* gnus
#+BEGIN_SRC elisp :tangle init.el
(setq gnus-select-method '(nnimap "mail.hover.com"))
#+END_SRC
* helm
#+BEGIN_SRC elisp :tangle init.el
(global-set-key (kbd "C-x b") 'helm-mini)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-h a") 'helm-apropos)
#+END_SRC
* org-mode
#+begin_src elisp :tangle init.el
(setq org-agenda-files '("~/org/")
org-agenda-file-regexp "\\.org$"
org-modules '(org-habit)
org-todo-repeat-to-state t
org-log-into-drawer t)
;; override that other confusing nonsense
(defun org-current-effective-time ()
"If `org-use-effective-time' is T, prompt for date+time.
Otherwise, use current time."
(if org-use-effective-time
(org-read-date nil t)
(org-current-time)))
(defun my/org-todo (&rest args)
"Modify org-todo prefix arg behavior"
(interactive "P")
(let ((org-use-effective-time current-prefix-arg))
(funcall (car args))))
(advice-add 'org-todo :around 'my/org-todo)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c x") 'org-capture)
#+end_src
* org-roam
#+begin_src elisp :tangle init.el
(setq org-roam-directory "~/org-roam"
org-roam-v2-ack t)
(require 'org-roam)
(org-roam-setup)
#+end_src
* Coding
** format-all
#+BEGIN_SRC elisp :tangle init.el
(require 'format-all)
(add-hook 'c-mode-hook 'format-all-mode)
#+END_SRC
** magit
#+BEGIN_SRC elisp :tangle init.el
(global-set-key (kbd "C-c m s") 'magit-status)
#+END_SRC

@ -1,10 +1,9 @@
(require 'package)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(package-refresh-contents)
(setq package-selected-packages
'(helm
@ -15,13 +14,7 @@
magit))
(package-install-selected-packages)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(menu-bar-mode -1)
(column-number-mode)
(setq inhibit-splash-screen t
backup-directory-alist '(("." . "~/.emacs.d/autosave")))
(load-theme 'misterioso)
(setq backup-directory-alist '(("." . "~/.emacs.d/autosave")))
(setq gnus-select-method '(nnimap "mail.hover.com"))
@ -35,7 +28,9 @@
org-todo-repeat-to-state t
org-log-into-drawer t)
;; override that other confusing nonsense
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c x") 'org-capture)
(defun org-current-effective-time ()
"If `org-use-effective-time' is T, prompt for date+time.
@ -51,9 +46,6 @@ Otherwise, use current time."
(funcall (car args))))
(advice-add 'org-todo :around 'my/org-todo)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c x") 'org-capture)
(setq org-roam-directory "~/org-roam"
org-roam-v2-ack t)
(require 'org-roam)

@ -0,0 +1,230 @@
My emacs configuration
* systemd service
Per [[https://www.emacswiki.org/emacs/EmacsAsDaemon#h5o-2][EmacsWiki]], you can enable emacs to run in daemon mode with this
in ~$HOME/.config/systemd/user/emacs.service~:
#+begin_src text :tangle .config/systemd/user/emacs.service
[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=on-failure
[Install]
WantedBy=default.target
#+end_src
Then enable and start with
#+begin_src bash
systemctl enable --user emacs
systemctl start --user emacs
#+end_src
and open new emacs frames with
#+begin_src bash
emacsclient -c
#+end_src
* Packages
Start with the basic setup of melpa and org elpa:
#+BEGIN_SRC elisp :tangle .emacs.d/init.el
(require 'package)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
#+END_SRC
** Package install
Since emacs is started once as a daemon and systemd service, it's
fine to take the time each startup to ensure packages are installed:
#+BEGIN_SRC elisp :tangle .emacs.d/init.el
(package-refresh-contents)
(setq package-selected-packages
'(helm
org-plus-contrib
org-roam
org-roam-bibtex
format-all
magit))
(package-install-selected-packages)
#+END_SRC
* Basic setup
Turn off annoying parts of the frame:
#+BEGIN_SRC elisp
(tool-bar-mode -1)
(scroll-bar-mode -1)
(menu-bar-mode -1)
#+END_SRC
Unclutter directories of backups:
#+begin_src elisp :tangle .emacs.d/init.el
(setq backup-directory-alist '(("." . "~/.emacs.d/autosave")))
#+end_src
Other bits and pieces:
#+BEGIN_SRC elisp
(column-number-mode)
(setq inhibit-splash-screen t)
(load-theme 'misterioso)
#+END_SRC
* gnus
Email login is handled by ~/.authinfo
#+BEGIN_SRC elisp :tangle .emacs.d/init.el
(setq gnus-select-method '(nnimap "mail.hover.com"))
#+END_SRC
* helm
Use helm for some basic tasks:
#+BEGIN_SRC elisp :tangle .emacs.d/init.el
(global-set-key (kbd "C-x b") 'helm-mini)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-h a") 'helm-apropos)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
#+END_SRC
* org-mode
Basic defaults config:
#+begin_src elisp :tangle .emacs.d/init.el
(setq org-agenda-files '("~/org/")
org-agenda-file-regexp "\\.org$"
org-modules '(org-habit)
org-todo-repeat-to-state t
org-log-into-drawer t)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c x") 'org-capture)
#+end_src
* Overriding org-current-effective-time
This is something that bugs me about org-mode. There should be a way
to easily input an arbitrary timestamp when marking items done. The
only such code I'm aware of is in ~org.el~:
#+begin_src elisp
(defun org-current-effective-time ()
"Return current time adjusted for `org-extend-today-until' variable."
(let* ((ct (org-current-time))
(dct (decode-time ct))
(ct1
(cond
(org-use-last-clock-out-time-as-effective-time
(or (org-clock-get-last-clock-out-time) ct))
((and org-use-effective-time (< (nth 2 dct) org-extend-today-until))
(encode-time 0 59 23 (1- (nth 3 dct)) (nth 4 dct) (nth 5 dct)))
(t ct))))
ct1))
(defun org-todo-yesterday (&optional arg)
"Like `org-todo' but the time of change will be 23:59 of yesterday."
(interactive "P")
(if (eq major-mode 'org-agenda-mode)
(apply 'org-agenda-todo-yesterday arg)
(let* ((org-use-effective-time t)
(hour (nth 2 (decode-time (org-current-time))))
(org-extend-today-until (1+ hour)))
(org-todo arg))))
#+end_src
This only allows you to make todo items as done yesterday, using a
rather roundabout method via the variable ~org-extend-today-until~,
which is clearly some guy's personal hack:
#+begin_src elisp
(defcustom org-extend-today-until 0
"The hour when your day really ends. Must be an integer.
This has influence for the following applications:
- When switching the agenda to \"today\". If it is still earlier than
the time given here, the day recognized as TODAY is actually yesterday.
- When a date is read from the user and it is still before the time given
here, the current date and time will be assumed to be yesterday, 23:59.
Also, timestamps inserted in capture templates follow this rule.
IMPORTANT: This is a feature whose implementation is and likely will
remain incomplete. Really, it is only here because past midnight seems to
be the favorite working time of John Wiegley :-)"
:group 'org-time
:type 'integer)
#+end_src
I typically mark tasks off on a printed list I keep in my wallet,
and update the org files in batch at the end of the day. I still
want to be able to keep track of /when/ items were completed, so
this is /my/ personal hack:
#+begin_src elisp :tangle .emacs.d/init.el
(defun org-current-effective-time ()
"If `org-use-effective-time' is T, prompt for date+time.
Otherwise, use current time."
(if org-use-effective-time
(org-read-date nil t)
(org-current-time)))
(defun my/org-todo (&rest args)
"Modify org-todo prefix arg behavior"
(interactive "P")
(let ((org-use-effective-time current-prefix-arg))
(funcall (car args))))
(advice-add 'org-todo :around 'my/org-todo)
#+end_src
* org-roam
Still working on setting this system up...
#+begin_src elisp :tangle .emacs.d/init.el
(setq org-roam-directory "~/org-roam"
org-roam-v2-ack t)
(require 'org-roam)
(org-roam-setup)
#+end_src
** org-protocol
Per [[https://www.orgroam.com/manual.html#Org_002droam-Protocol][org-roam.com]], you can set up org-roam to capture content from
external applications. Emacs config:
#+begin_src elisp :tangle .emacs.d/init.el
(require 'org-roam-protocol)
#+end_src
Then add this to
~$HOME/.local/share/applications/org-protocol.desktop~:
#+begin_src text :tangle .local/share/applications/org-protocol.desktop
[Desktop Entry]
Name=Org-Protocol
Exec=emacsclient %u
Icon=emacs-icon
Type=Application
Terminal=false
MimeType=x-scheme-handler/org-protocol
#+end_src
and finally associate org-protocol:// links with the application:
#+begin_src bash
xdg-mime default org-protocol.desktop x-scheme-handler/org-protocol
#+end_src
You can also create new nodes with a bookmarklet:
#+begin_src javascript
javascript:location.href =
'org-protocol://roam-ref?template=r&ref='
+ encodeURIComponent(location.href)
+ '&title='
+ encodeURIComponent(document.title)
+ '&body='
+ encodeURIComponent(window.getSelection())
#+end_src
* Coding
** format-all
#+BEGIN_SRC elisp :tangle .emacs.d/init.el
(require 'format-all)
(add-hook 'c-mode-hook 'format-all-mode)
#+END_SRC
** magit
#+BEGIN_SRC elisp :tangle .emacs.d/init.el
(global-set-key (kbd "C-c m s") 'magit-status)
#+END_SRC

@ -1 +0,0 @@
xdg-mime default org-protocol.desktop x-scheme-handler/org-protocol
Loading…
Cancel
Save