[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX] treating a multitude of paragraphs
From: |
Andreas Roehler |
Subject: |
[AUCTeX] treating a multitude of paragraphs |
Date: |
Sat, 07 Apr 2007 19:50:16 +0200 |
User-agent: |
Thunderbird 1.5.0.4 (X11/20060516) |
Hi,
I'm looking for a way to treat several paragraphs with one call.
For example to quote them.
Exists a function to do this? Couldn't figure it out.
In case not:
Can the draft below considered a possible starting
point to write a more general function - which not just
quotes, but does all possible things?
;; `long-quote-start' would be turned in a general form
(setq long-quote-start "\\begin{quote}")
(setq long-quote-end "\\end{quote}")
;; later: tx-do-with-paragraphs-what-you-want-to or so
(defun tx-quote-paragraphs (&optional arg beg end)
"Operates on region, when active.
With arg from point-min, default is from current pos "
(interactive "*P")
(let ((beg (if beg beg
(cond ((and mark-active transient-mark-mode)
(region-beginning))
((when arg (point-min)))
(t (point)))))
(end (if end end
(cond ((and mark-active transient-mark-mode)
(1+ (region-end)))
(t (point-max)))))
(old-buf-size (buffer-size)))
(goto-char beg)
(insert long-quote-start)
(new-end end old-buf-size)
(LaTeX-forward-paragraph)
(insert long-quote-end)
(new-end end old-buf-size)
(goto-char end)
(insert long-quote-end)))
(defun new-end (end old-buf-size)
"Adapts end position after insertion/deletion
Expects vars `end' and `old-buf-size' to be set in current context"
(< old-buf-size (buffer-size))
(setq end (+ end (- (buffer-size) old-buf-size)))
(setq end (- end (- (buffer-size) old-buf-size))))
Thanks
Andreas Roehler
- [AUCTeX] treating a multitude of paragraphs,
Andreas Roehler <=