diff options
author | Tom Willemse | 2022-02-03 21:58:09 -0800 |
---|---|---|
committer | Tom Willemse | 2022-02-03 21:58:09 -0800 |
commit | 5834c0a7ef95819e528ed26c9ef7181d89a02047 (patch) | |
tree | 3402ed8f9ab02ba410f10e4afc2c9f6ce5f2a2b1 | |
parent | d4eea37a8f406cf62eb6e59b04267f5d846af457 (diff) | |
download | emacs-config-5834c0a7ef95819e528ed26c9ef7181d89a02047.tar.gz emacs-config-5834c0a7ef95819e528ed26c9ef7181d89a02047.zip |
[oni-cmake] Add function to narrow the buffer to the current defun
-rw-r--r-- | oni-cmake.el | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/oni-cmake.el b/oni-cmake.el index 5524176..16968e6 100644 --- a/oni-cmake.el +++ b/oni-cmake.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse <tom@ryuslash.org> ;; Keywords: local -;; Version: 2021.0730.231115 +;; Version: 2022.0203.215032 ;; Package-Requires: (cmake-mode oni-company oni-flycheck oni-lsp cmake-font-lock eldoc-cmake) ;; This program is free software; you can redistribute it and/or modify @@ -26,6 +26,7 @@ ;;; Code: +(require 'cmake-mode) (require 'compile) (require 'flycheck) @@ -34,6 +35,19 @@ (setq-local comment-auto-fill-only-comments t) (auto-fill-mode)) +(defun oni-cmake-narrow-to-defun (&optional _include-comments) + "Narrow the current buffer the the function around point. +_INCLUDE-COMMENTS is currently ignored." + (interactive) + (save-excursion + (let ((end (progn (cmake-end-of-defun) + (point))) + (beginning (progn (cmake-beginning-of-defun) + (point)))) + (narrow-to-region beginning end)))) + +(define-key cmake-mode-map (kbd "C-x n d") #'oni-cmake-narrow-to-defun) + (add-hook 'cmake-mode-hook 'cmake-font-lock-activate) (add-hook 'cmake-mode-hook 'company-mode) (add-hook 'cmake-mode-hook 'display-fill-column-indicator-mode) |