ENH commit git buffers in emacs natively
This commit is contained in:
parent
acef51b7d6
commit
5af5d4952e
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
### Add org file changes to git repo
|
||||||
|
|
||||||
|
for REPO in $1
|
||||||
|
do
|
||||||
|
echo "repository: $REPO"
|
||||||
|
eval "cd $REPO"
|
||||||
|
# check for errors
|
||||||
|
if ! git fsck --strict > /dev/null 2>&1; then
|
||||||
|
notify-send "Org git commit failed."
|
||||||
|
fi
|
||||||
|
# remove deleted files
|
||||||
|
git ls-files --deleted -z | xargs -0 git rm >/dev/null 2>&1
|
||||||
|
# add new files
|
||||||
|
git add . >/dev/null 2>&1
|
||||||
|
git commit -m "$(date)"
|
||||||
|
# push
|
||||||
|
git push origin master
|
||||||
|
done
|
||||||
|
echo Done
|
22
etc/conf.org
22
etc/conf.org
|
@ -341,6 +341,17 @@ If FRONT is t, do to the front of current values instead of the back."
|
||||||
(--each
|
(--each
|
||||||
(where-is-internal f keymap nil nil)
|
(where-is-internal f keymap nil nil)
|
||||||
(define-key keymap it nil)))
|
(define-key keymap it nil)))
|
||||||
|
|
||||||
|
|
||||||
|
(defun nd/run-at-hour-minute (hh mm rep cmd &rest args)
|
||||||
|
"Run CMD starting at next integral HH and MM repeating every REP seconds.
|
||||||
|
|
||||||
|
For example, to run every hour at 45 minutes HH would be 1 and MM would be 45."
|
||||||
|
(let* ((m (* mm 60))
|
||||||
|
(h (* hh 3600))
|
||||||
|
(now (float-time))
|
||||||
|
(next (- (+ m (* h (ceiling (/ (- now m) h)))) now)))
|
||||||
|
(apply #'run-at-time next rep cmd args)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** interactive
|
** interactive
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
@ -1719,14 +1730,21 @@ Additionally, using specialized file variables makes it much easier and faster t
|
||||||
(org-x-get-reference-files :maxlevel . 9)))
|
(org-x-get-reference-files :maxlevel . 9)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** autosave
|
*** autosave
|
||||||
Save all org buffers 1 minute before the hour.
|
Save all org buffers 1 minute before the hour, then commit whatever I saved.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defun nd/org-save-all-org-buffers ()
|
(defun nd/org-save-all-org-buffers ()
|
||||||
"Save org buffers without confirmation or message (unlike default)."
|
"Save org buffers without confirmation or message (unlike default)."
|
||||||
(save-some-buffers t (lambda () (derived-mode-p 'org-mode)))
|
(save-some-buffers t (lambda () (derived-mode-p 'org-mode)))
|
||||||
(when (featurep 'org-id) (org-id-locations-save)))
|
(when (featurep 'org-id) (org-id-locations-save)))
|
||||||
|
|
||||||
(run-at-time "00:59" 3600 #'nd/org-save-all-org-buffers)
|
(defun nd/org-commit-repos ()
|
||||||
|
"Commit org git repos automatically"
|
||||||
|
(let* ((journal-path (f-join org-directory "journal"))
|
||||||
|
(cmd (format "autogit \"%s\" \"%s\"" org-directory journal-path)))
|
||||||
|
(async-shell-command cmd)))
|
||||||
|
|
||||||
|
(nd/run-at-hour-minute 1 59 3600 #'nd/org-save-all-org-buffers)
|
||||||
|
(nd/run-at-hour-minute 1 0 3600 #'nd/org-commit-repos)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** stateless configuration
|
*** stateless configuration
|
||||||
=org-ml= provides stateless functions for operating on org buffers.
|
=org-ml= provides stateless functions for operating on org buffers.
|
||||||
|
|
Loading…
Reference in New Issue