Skip to content

Instantly share code, notes, and snippets.

View mwfogleman's full-sized avatar

Tasshin Fogleman mwfogleman

View GitHub Profile
@mwfogleman
mwfogleman / org-go-speed.el
Last active January 30, 2019 09:09
Org-Mode: Go to the heading of an element, so you can use speed commands
; Speed commands are really useful, but I often want to make use of
; them when I'm not at the beginning of a header. This command brings
; you back to the beginning of an item's header, so that you can do
; speed commands.
(defun org-go-speed ()
"Goes to the beginning of an element's header, so that you can
execute speed commands."
(interactive)
(when (equal major-mode 'org-mode)
@mwfogleman
mwfogleman / gist:95cc60c87a9323876c6c
Last active May 19, 2018 23:28
Emacs: narrow-or-widen-dwim
(defun narrow-or-widen-dwim ()
"If the buffer is narrowed, it widens. Otherwise, it narrows to region, or Org subtree."
(interactive)
(cond ((buffer-narrowed-p) (widen))
((region-active-p) (narrow-to-region (region-beginning) (region-end)))
((equal major-mode 'org-mode) (org-narrow-to-subtree))
(t (error "Please select a region to narrow to"))))
;; I bind this key to C-c n, using the bind-key function that comes with use-package.
(bind-key "C-c n" 'narrow-or-widen-dwim)