[Top][All Lists]

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

Re: [AUCTeX-devel] Narrowing

From: Nicolas Richard
Subject: Re: [AUCTeX-devel] Narrowing
Date: Thu, 17 Oct 2013 11:49:13 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)


Mosè Giordano <address@hidden> 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)
      (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)))


reply via email to

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