mirror of
https://codeberg.org/scip/dot-emacs.git
synced 2025-12-16 20:10:58 +01:00
added global narrowing function, disable narrow prefix in orgmode
This commit is contained in:
@@ -21,6 +21,39 @@
|
||||
|
||||
(add-hook 'post-command-hook 'tvd-narrowed-fringe-status)
|
||||
|
||||
;; via https://endlessparentheses.com/emacs-narrow-or-widen-dwim.html
|
||||
;; pure genius, never ever have to think about how to widen
|
||||
(defun narrow-or-widen-dwim (p)
|
||||
"Widen if buffer is narrowed, narrow-dwim otherwise.
|
||||
Dwim means: region, org-src-block, org-subtree, or
|
||||
defun, whichever applies first. Narrowing to
|
||||
org-src-block actually calls `org-edit-src-code'.
|
||||
|
||||
With prefix P, don't widen, just narrow even if buffer
|
||||
is already narrowed."
|
||||
(interactive "P")
|
||||
(declare (interactive-only))
|
||||
(cond ((and (buffer-narrowed-p) (not p)) (widen))
|
||||
((region-active-p)
|
||||
(narrow-to-region (region-beginning)
|
||||
(region-end)))
|
||||
((derived-mode-p 'org-mode)
|
||||
;; `org-edit-src-code' is not a real narrowing
|
||||
;; command. Remove this first conditional if
|
||||
;; you don't want it.
|
||||
(cond ((ignore-errors (org-edit-src-code) t)
|
||||
(delete-other-windows))
|
||||
((ignore-errors (org-narrow-to-block) t))
|
||||
(t (org-narrow-to-subtree))))
|
||||
((derived-mode-p 'latex-mode)
|
||||
(LaTeX-narrow-to-environment))
|
||||
(t (narrow-to-defun))))
|
||||
|
||||
;; This line actually replaces Emacs' entire narrowing
|
||||
;; keymap, that's how much I like this command. Only
|
||||
;; copy it if that's what you want.
|
||||
(define-key ctl-x-map "n" #'narrow-or-widen-dwim)
|
||||
|
||||
|
||||
(provide 'init-narrow)
|
||||
;;; init-narrow.el ends here
|
||||
|
||||
@@ -164,6 +164,9 @@ down and unfold it, otherwise jump paragraph as usual."
|
||||
; run presenter, org-present must be installed and loadedwhite
|
||||
(local-set-key (kbd "C-p") 'org-present)
|
||||
|
||||
;; we need to remove the narrowing prefix, because we use 'narrow-or-widen-dwim globally
|
||||
(define-key org-mode-map (kbd "C-x n") nil)
|
||||
|
||||
; todo colors
|
||||
(setq org-todo-keyword-faces '(
|
||||
("TODO" . (:foreground "deepskyblue" :weight bold))
|
||||
|
||||
Reference in New Issue
Block a user