From 5834c0a7ef95819e528ed26c9ef7181d89a02047 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Thu, 3 Feb 2022 21:58:09 -0800 Subject: [oni-cmake] Add function to narrow the buffer to the current defun --- oni-cmake.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'oni-cmake.el') 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 ;; 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) -- cgit v1.2.3-54-g00ecf