auctex-devel
[Top][All Lists]
Advanced

[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: Fri, 10 Mar 2017 11:46:05 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2

Uwe Brauer <address@hidden> writes:

> First of all, thanks very very much, this is really sophisticated at
> least for me, then some clarification.

Hi Uwe,

you're welcome.  I can think of one situation where my suggestion
chokes:

\begin{enumerate}
* move cursor to this line and run the function
\item First we do blabla 
  and so on
\item the we do
\end{enumerate}

Here an improved version which also works for \bibitem's:

--8<---------------cut here---------------start------------->8---
(defun ub/delete-item ()
  (interactive)
  (let* ((currenv (LaTeX-current-environment))
         (beg-pos (save-excursion
                    (LaTeX-find-matching-begin)
                    (point)))
         (end-pos (save-excursion
                    (LaTeX-find-matching-end)
                    (point)))
         (item-regexp "^[ \t]*\\\\\\(bib\\)?item")
         (end-regexp (concat "^[ \t]*\\\\end{" currenv "}"))
         item-start item-end)
    (beginning-of-line)
    (if (looking-at item-regexp)
        ;; We are in the same line as in \item
        (progn
          (setq item-start (point))
          (setq item-end
                (progn
                  (or (re-search-forward item-regexp end-pos t 2)
                      (re-search-forward end-regexp end-pos t))
                  (end-of-line 0)
                  (point))))
      ;; We are somewhere within \item
      (setq item-end
            (progn
              (or (re-search-forward item-regexp end-pos t)
                  (re-search-forward end-regexp end-pos t))
              (end-of-line 0)
              (point)))
      (setq item-start (re-search-backward item-regexp beg-pos t)))
    (if (and item-start item-end)
        (progn
          (delete-region item-start item-end)
          (when (looking-at "^$")
            (kill-line))
          (indent-according-to-mode))
      (message "No start of item found."))))
--8<---------------cut here---------------end--------------->8---

>     -  I suggest to include such a function or a similar in auctex core,
>        what do others think? Or maybe ae/mark-item as well? I mean
>        replacing

Yes, let's see what others think.

Best, Arash



reply via email to

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