[Top][All Lists]

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

Re: [AUCTeX-devel] feature proposal kill an next item in a enumerate lik

From: Arash Esbati
Subject: Re: [AUCTeX-devel] feature proposal kill an next item in a enumerate like environment
Date: Thu, 09 Mar 2017 20:20:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2

Uwe Brauer <address@hidden> writes:

> Please consider.
> \documentclass[12pt]{article}
> \begin{document}
> \begin{enumerate}
>   \item First we do blabla 
>         and so on
>   \item the we do
> \end{enumerate}
> \end{document}
> I would now set the cursor before the first item and call the function
> (to-be-implemented) and I obtain
> \begin{enumerate}
>   \item the we do
> \end{enumerate}
> \end{document}
> Any idea how to do that?

Hi Uwe,

I'm not sure if AUCTeX has a function to detect and/or mark an item (and
I haven't checked).  But you could roll your own function, maybe like

--8<---------------cut here---------------start------------->8---
(defun ub/delete-item ()
  (let ((currenv (LaTeX-current-environment))
        (beg-pos (save-excursion
        (end-pos (save-excursion
        item-start item-end)
    (if (looking-at "^[ \t]*\\\\item")
        ;; We are in the same line as in \item
          (setq item-start (point))
          (setq item-end (progn (or (re-search-forward "^[ \t]*\\\\item" 
end-pos t 2)
                                    (re-search-forward (concat "^[ 
\t]*\\\\end{" currenv "}")
                                                       end-pos t))
                                (end-of-line 0)
      ;; We are somewhere in \item
      (setq item-end (progn (or (re-search-forward "^[ \t]*\\\\item" end-pos t)
                                (re-search-forward (concat "^[ \t]*\\\\end{" 
currenv "}")
                                                   end-pos t))
                            (end-of-line 0)
      (setq item-start (re-search-backward "^[ \t]*\\\\item" beg-pos t)))
    (delete-region item-start item-end)
    (when (looking-at "^$")
--8<---------------cut here---------------end--------------->8---

Best, Arash

reply via email to

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