[oni-cmake] Add function to narrow the buffer to the current defun
This commit is contained in:
parent
d4eea37a8f
commit
5834c0a7ef
1 changed files with 15 additions and 1 deletions
16
oni-cmake.el
16
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)
|
||||
|
|
Loading…
Reference in a new issue