Add 'org-narrow-to-table' to 'narrow-or-widen-dwim'
This commit is contained in:
parent
e1715c2e3e
commit
424322a129
14
README.org
14
README.org
@ -1463,12 +1463,20 @@ Narrowing means focusing in on some portion of the buffer and widening means
|
||||
focussing out on the whole buffer. This allows to concentrate temporarily on
|
||||
for instance a particular function or paragraph by removing clutter. The "Do
|
||||
What I Mean" [[https://endlessparentheses.com/emacs-narrow-or-widen-dwim.html][narrow-or-widen-dwim]] function allows to toggle between narrowed and
|
||||
widened buffer states.
|
||||
widened buffer states. Here, the function =narrow-or-widen-dwim= operates also
|
||||
on tables by means of =org-narrow-to-table=.
|
||||
|
||||
#+caption[Configure =narrow-or-widen-dwim=]:
|
||||
#+caption: Configure =narrow-or-widen-dwim=.
|
||||
#+label: lst:configure-narrow-or-widen-dwim
|
||||
#+name: lst:configure-narrow-or-widen-dwim
|
||||
#+begin_src emacs-lisp
|
||||
(defun org-narrow-to-table ()
|
||||
"Narrow buffer to current table."
|
||||
(interactive)
|
||||
(if (org-table-p)
|
||||
(narrow-to-region (org-table-begin) (org-table-end))
|
||||
(user-error "Not in a table")))
|
||||
|
||||
(defun narrow-or-widen-dwim (p)
|
||||
"Widen if buffer is narrowed, narrow-dwim otherwise.
|
||||
Dwim means: region, org-src-block, org-subtree, or defun,
|
||||
@ -1486,6 +1494,7 @@ widened buffer states.
|
||||
((derived-mode-p 'org-mode)
|
||||
(or (ignore-errors (org-edit-src-code))
|
||||
(ignore-errors (org-narrow-to-block))
|
||||
(ignore-errors (org-narrow-to-table))
|
||||
(org-narrow-to-subtree)))
|
||||
((derived-mode-p 'latex-mode)
|
||||
(LaTeX-narrow-to-environment))
|
||||
@ -1493,6 +1502,7 @@ widened buffer states.
|
||||
(TeX-narrow-to-group))
|
||||
(t (narrow-to-defun))))
|
||||
|
||||
(define-key ctl-x-map (kbd "n t") #'org-narrow-to-table)
|
||||
(define-key ctl-x-map (kbd "C-n") #'narrow-or-widen-dwim)
|
||||
#+end_src
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user