diff options
author | William Carroll <wpcarro@gmail.com> | 2018-09-10T18·51-0400 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2018-09-10T18·53-0400 |
commit | 17ee0e400bef47c371afcae76037f9ea6a44ad13 (patch) | |
tree | 0e5efee6f00e402890e91f3eceb4b29408a498b6 /configs/shared/emacs/.emacs.d/elpa/evil-commentary-20170413.751/evil-commentary-integration.el | |
parent | 8b2fadf4776b7ddb4a67b4bc8ff6463770e56028 (diff) |
Support Vim, Tmux, Emacs with Stow
After moving off of Meta, Dotfiles has a greater responsibility to manage configs. Vim, Tmux, and Emacs are now within Stow's purview.
Diffstat (limited to 'configs/shared/emacs/.emacs.d/elpa/evil-commentary-20170413.751/evil-commentary-integration.el')
-rw-r--r-- | configs/shared/emacs/.emacs.d/elpa/evil-commentary-20170413.751/evil-commentary-integration.el | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/configs/shared/emacs/.emacs.d/elpa/evil-commentary-20170413.751/evil-commentary-integration.el b/configs/shared/emacs/.emacs.d/elpa/evil-commentary-20170413.751/evil-commentary-integration.el new file mode 100644 index 000000000000..0d2760e73077 --- /dev/null +++ b/configs/shared/emacs/.emacs.d/elpa/evil-commentary-20170413.751/evil-commentary-integration.el @@ -0,0 +1,37 @@ +(declare-function org-in-src-block-p "org") + +(defmacro evil-commentary/org-babel-do-in-edit-buffer (beg end &rest body) + "Do `org-babel-do-in-edit-buffer' and restore view. + +Return the same value as `org-babel-do-in-edit-buffer'. Save top +line of current window and restore it if sucess." + (declare (indent defun)) + `(when (and (fboundp 'org-babel-do-in-edit-buffer) + (org-in-src-block-p t)) + (let ((top-line (line-number-at-pos (window-start))) + (current-point (point)) + found) + (push-mark ,beg) + (goto-char ,end) + (setq mark-active t) + (setq found (eval '(org-babel-do-in-edit-buffer + ,@body))) + (pop-mark) + (if (not found) + (goto-char current-point) + (save-excursion + (scroll-up 1) ; stupid fix + (goto-char (point-min)) + (forward-line (1- top-line)) + (recenter 0))) + found))) + +;;;###autoload +(defun evil-commentary/org-comment-or-uncomment-region (beg end) + "Comment function for `org-mode'." + (interactive "r") + (unless (evil-commentary/org-babel-do-in-edit-buffer beg end + (call-interactively 'evil-commentary)) + (comment-or-uncomment-region beg end))) + +(provide 'evil-commentary-integration) |