Re: [AUCTeX-devel] Narrowing

2013-10-17 Thread Nicolas Richard
Hello,

Mosè Giordano  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


Re: [AUCTeX-devel] Narrowing

2013-10-17 Thread Tassilo Horn
Mosè Giordano  writes:

> I suggest to bind the first to `C-c n e' and the second to `C-c n g'.

C-c  bindings are reserved for the user.  But the bindings e
and g are still free in the standard `narrow-map', so I'd just put them
there (and hope that no other standard narrowing bindings emerge).

> Do you think it's valuable to add them to AUCTeX?

Yes, I think they are very useful for people that like narrowing in
general.

> If yes, should we disable them by default?

Yes, I think so.  At least the other standard narrowing commands are
disabled by default, too.

> I didn't test these functions thoroughly, so improvements are welcome.

I've tried them briefly, and they did what they are supposed to do. ;-)

Bye,
Tassilo


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