Skip to content

Instantly share code, notes, and snippets.

@lawlist
lawlist / org-archive-save-buffer
Last active September 4, 2018 22:56
Save an org-archive buffer.
(require 'org)
(setq org-archive-location "~/Dropbox/logs/archive.org::")
(defun org-archive-save-buffer ()
(let ((afile (org-extract-archive-file (org-get-local-archive-location))))
(if (file-exists-p afile)
(let ((buffer (find-file-noselect afile)))
(if (y-or-n-p (format "Save (%s)" buffer))
(with-current-buffer buffer
@lawlist
lawlist / buffer-menu.el
Last active June 28, 2019 06:00
A port of the Xemacs buffers menu-bar feature that works with Emacs 26.
This gist has been superseded by the following repository:
https://github.com/lawlist/buffer-menu
https://emacs.stackexchange.com/q/34314/2287
undo-tree: Create a separate copy of `buffer-undo-tree` in Emacs 26.0.50
Q: Using Emacs 26.0.50, how to copy the buffer-undo-tree preserving the structure and create a completely separate copy -- including the hash-table (aka object-pool)?
When using Emacs 25.2.1, setting the hash-table of the copy of buffer-undo-tree to a nil value does not alter the original buffer-undo-tree.
When using Emacs 26.0.50 (master branch), setting the hash-table of the copy of buffer-undo-tree to a nil value alters the original buffer-undo-tree -- setting it to nil.
@lawlist
lawlist / pop-to-buffer
Last active June 28, 2019 05:35
Take control of pop-to-buffer.
(require 'cl)
(defun my-pop-to-buffer (buffer &optional action norecord)
(message "buffer: %s | action: %s | norecord: %s" buffer action norecord))
(defun test-fn ()
"Doc-string."
(interactive)
(cl-letf (((symbol-function 'pop-to-buffer) #'my-pop-to-buffer))
(pop-to-buffer (current-buffer))))
@lawlist
lawlist / nsspellchecker_emacs25.diff
Created November 4, 2016 03:30
Native splellchecking on OSX -- extracted from Aquamacs -- patch applies to Emacs 25 branch as of November 1, 2016 commit 5043e0a7e06dbf6507a59736e55bdde69d9a2a4e
diff --git a/lisp/term/common-win.el b/lisp/term/common-win.el
index 937e47f..165263a 100644
--- a/lisp/term/common-win.el
+++ b/lisp/term/common-win.el
@@ -73,6 +73,8 @@
(cons (logior (lsh 0 16) 12) 'ns-new-frame)
(cons (logior (lsh 0 16) 13) 'ns-toggle-toolbar)
(cons (logior (lsh 0 16) 14) 'ns-show-prefs)
+ (cons (logior (lsh 0 16) 20) 'ns-check-spelling)
+ (cons (logior (lsh 0 16) 21) 'ns-spelling-change)
@lawlist
lawlist / nsspellchecker.diff
Last active May 30, 2016 16:45
nsspellchecker -- extracted code from Aquamacs and created unofficial draft patch for generic/vanilla build of Emacs master branch as of commit (05/29/2016) 76fb19b359dec8556dc66dbac3ad3d333feea3c3.
diff --git a/lisp/term/common-win.el b/lisp/term/common-win.el
index 937e47f..165263a 100644
--- a/lisp/term/common-win.el
+++ b/lisp/term/common-win.el
@@ -73,6 +73,8 @@
(cons (logior (lsh 0 16) 12) 'ns-new-frame)
(cons (logior (lsh 0 16) 13) 'ns-toggle-toolbar)
(cons (logior (lsh 0 16) 14) 'ns-show-prefs)
+ (cons (logior (lsh 0 16) 20) 'ns-check-spelling)
+ (cons (logior (lsh 0 16) 21) 'ns-spelling-change)