celano <[email protected]> writes:

Hi Celano,

> Good morning and happy new year!

Thanks, I wish the same to you!

> I'd like to hide a section or a chapter in my file.tex, using
> tex-fold-mode
>
> I found environments and macros, but nothing about a hole chapter or
> section

No, `TeX-fold-mode' doesn't work for sectioning commands.  But for those
you can use `outline-minor-mode'.  AUCTeX already sets that up to work
with LaTeX documents.  Have a look at the emacs docs (info
"(emacs)Outline Mode").

For me, the standard outline-minor-mode keys (C-c @ ...) are too hard to
remember and inconvenient.  So I have some additional code that makes
TAB [or whatever key you like] on a outline heading (like \section{foo}
in a LaTeX doc) cycle through the states "collapsed", "shown with
children collapsed", and "everything shown".

--8<---------------cut here---------------start------------->8---
(defmacro define-context-key (keymap key dispatch)
  "Define KEY in KEYMAP to execute according to DISPATCH.

DISPATCH is a form that is evaluated and should return the
command to be executed.

If DISPATCH returns nil, then the command normally bound to KEY
will be executed.

Example:

  (define-context-key hs-minor-mode-map
     (kbd \"<C-tab>\")
     (cond
      ((not (hs-already-hidden-p))
       'hs-hide-block)
      ((hs-already-hidden-p)
       'hs-show-block)))

This will make <C-tab> show a hidden block.  If the block is
shown, then it'll be hidden."
  `(define-key ,keymap ,key
     `(menu-item "context-key" ignore
                 :filter ,(lambda (&optional ignored)
                            ,dispatch))))

(defun th-outline-context-p ()
  "Non-nil if `point' is on an outline-heading."
  (save-excursion
    (goto-char (line-beginning-position))
    (looking-at outline-regexp)))

(define-context-key outline-minor-mode-map
  (kbd "TAB")
  (when (th-outline-context-p)
    'org-cycle))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo


_______________________________________________
auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/auctex

Reply via email to