auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-devel] Narrowing


From: Mosè Giordano
Subject: [AUCTeX-devel] Narrowing
Date: Wed, 16 Oct 2013 22:21:06 +0200

Hi all,

I like narrowing and I wrote these two simple functions to narrow
(La)TeX code to the current environment and group:

--8<---------------cut here---------------start------------->8---
(defun LaTeX-narrow-to-environment (&optional arg)
  "Make text outside current environment invisible.
With optional ARG keep visible that number of enclosing
environmens."
  (interactive "p")
  (save-excursion
    (if (equal (LaTeX-current-environment arg) "document")
    (message "Nothing to be narrowed here.")
      (widen)
      (LaTeX-mark-environment arg)
      (narrow-to-region (mark) (point)))))

(defun TeX-narrow-to-group ()
  "Make text outside current group invisible."
  (interactive)
  (save-excursion
    (widen)
    (let ((opoint (point))
      beg end)
      (if (null (search-backward "{" nil t))
      (message "Nothing to be narrowed here.")
    (setq beg (point))
    (forward-sexp)
    (setq end (point))
    (if (< end opoint)
        (message "Nothing to be narrowed here.")
      (narrow-to-region beg end))))))
--8<---------------cut here---------------end--------------->8---

I suggest to bind the first to `C-c n e' and the second to `C-c n g'.
Do you think it's valuable to add them to AUCTeX?  If yes, should we
disable them by default?  I didn't test these functions thoroughly, so
improvements are welcome.

Bye,
Mosè



reply via email to

[Prev in Thread] Current Thread [Next in Thread]