1
0
Fork 0

[oni-cmake] Add function to narrow the buffer to the current defun

This commit is contained in:
Tom Willemse 2022-02-03 21:58:09 -08:00
parent d4eea37a8f
commit 5834c0a7ef

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org> ;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local ;; 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) ;; 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 ;; This program is free software; you can redistribute it and/or modify
@ -26,6 +26,7 @@
;;; Code: ;;; Code:
(require 'cmake-mode)
(require 'compile) (require 'compile)
(require 'flycheck) (require 'flycheck)
@ -34,6 +35,19 @@
(setq-local comment-auto-fill-only-comments t) (setq-local comment-auto-fill-only-comments t)
(auto-fill-mode)) (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 'cmake-font-lock-activate)
(add-hook 'cmake-mode-hook 'company-mode) (add-hook 'cmake-mode-hook 'company-mode)
(add-hook 'cmake-mode-hook 'display-fill-column-indicator-mode) (add-hook 'cmake-mode-hook 'display-fill-column-indicator-mode)