Hello,

Mosè Giordano <giordano.m...@libero.it> writes:
> I like narrowing and I wrote these two simple functions to narrow
> (La)TeX code to the current environment and group:

FWIW, I had my own version of LaTeX-narrow-to-environment (see below) in
which I tried to avoid modifying the mark (by copying code from
LaTeX-mark-environment). Perhaps this calls for a function
LaTeX-inner-bounds-of-environment-at-point (possibly relying on
thingatpt.el), which would be called by both functions. What do you
think ?

I must warn though that I'm not entirely happy with my version wrt to
handling newlines at the end of environement. Never cared enough to fix
it, though.

(defun LaTeX-narrow-to-environment (&optional count)
  "Narrow buffer to the current environment."
  (interactive "p")
  (setq count (if count (abs count) 1))
  (let ((cur (point)) beg end)
    (save-excursion
      (dotimes (c count) (LaTeX-find-matching-end))
      (search-backward "\\")
      (if (bolp) (backward-char)) ; don't include newline to region.
      (setq end (point))
      (goto-char cur)
      (dotimes (c count) (LaTeX-find-matching-begin))
      (search-forward "}")
      (if (eolp) (forward-char)) ; don't include newline
      (setq beg (point)))
    (narrow-to-region beg end)))


-- 
Nico.


_______________________________________________
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to