auctex-devel
[Top][All Lists]
Advanced

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

[AUCTeX-devel] Improvement for LaTeX-item-list


From: Pieter Pareit
Subject: [AUCTeX-devel] Improvement for LaTeX-item-list
Date: Thu, 22 Aug 2019 14:52:36 +0200

Developers,

Can I suggest the following change for LaTeX-item-list:


diff --git a/latex.el b/latex.el
index 17a44624..a0fdecb1 100644
--- a/latex.el
+++ b/latex.el
@@ -1324,6 +1324,11 @@ out."
   "A list of environments where items have a special syntax.
 The cdr is the name of the function, used to insert this kind of
items.")
 
+(defun current-line-empty-p ()
+  (save-excursion
+    (beginning-of-line)
+    (looking-at "[[:space:]]*$")))
+
 (defun LaTeX-insert-item ()
   "Insert a new item in an environment.
 You may use `LaTeX-item-list' to change the routines used to insert
the item."
@@ -1332,7 +1337,7 @@ You may use `LaTeX-item-list' to change the
routines used to insert the item."
     (when (and (TeX-active-mark)
               (> (point) (mark)))
       (exchange-point-and-mark))
-    (unless (bolp) (LaTeX-newline))
+    (unless (current-line-empty-p) (LaTeX-newline))
     (if (assoc environment LaTeX-item-list)
        (funcall (cdr (assoc environment LaTeX-item-list)))
       (TeX-insert-macro "item"))


Before, there was no newline when the point was at the beginning of the
line. But it often happens, with auto intending, that point somewhere
in the middle of the line.

I have looked for a function to check if the current line is empty, but
did not find one inside of emacs. Above, I'm using a piece of code from
stackoverflow for current-line-empty-p

Pieter




reply via email to

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