auctex-devel
[Top][All Lists]
Advanced

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

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


From: Arash Esbati
Subject: Re: [AUCTeX-devel] Improvement for LaTeX-item-list
Date: Fri, 23 Aug 2019 23:19:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50

Hi Pieter,

Pieter Pareit <address@hidden> writes:

> 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.

Thanks for your suggestion.  I'm not sure if that change would probably
break other things---`LaTeX-item-insert' is used in many places.  If you
have excessive white spaces, how about using `M-x whitespace-cleanup
RET'?
,----
| whitespace-cleanup is an autoloaded interactive compiled Lisp function
| in ‘whitespace.el’.
| 
| (whitespace-cleanup)
| 
| Cleanup some blank problems in all buffer or at region.
| 
| It usually applies to the whole buffer, but in transient mark
| mode when the mark is active, it applies to the region.  It also
| applies to the region when it is not in transient mark mode, the
| mark is active and C-u was pressed just before
| calling ‘whitespace-cleanup’ interactively.
| 
| See also ‘whitespace-cleanup-region’.
| 
| The problems cleaned up are:
| 
| 1. empty lines at beginning of buffer.
| 2. empty lines at end of buffer.
|    If ‘whitespace-style’ includes the value ‘empty’, remove all
|    empty lines at beginning and/or end of buffer.
| 
| 3. ‘tab-width’ or more SPACEs at beginning of line.
|    If ‘whitespace-style’ includes the value ‘indentation’:
|    replace ‘tab-width’ or more SPACEs at beginning of line by
|    TABs, if ‘indent-tabs-mode’ is non-nil; otherwise, replace TABs by
|    SPACEs.
|    If ‘whitespace-style’ includes the value ‘indentation::tab’,
|    replace ‘tab-width’ or more SPACEs at beginning of line by TABs.
|    If ‘whitespace-style’ includes the value ‘indentation::space’,
|    replace TABs by SPACEs.
| 
| 4. SPACEs before TAB.
|    If ‘whitespace-style’ includes the value ‘space-before-tab’:
|    replace SPACEs by TABs, if ‘indent-tabs-mode’ is non-nil;
|    otherwise, replace TABs by SPACEs.
|    If ‘whitespace-style’ includes the value
|    ‘space-before-tab::tab’, replace SPACEs by TABs.
|    If ‘whitespace-style’ includes the value
|    ‘space-before-tab::space’, replace TABs by SPACEs.
| 
| 5. SPACEs or TABs at end of line.
|    If ‘whitespace-style’ includes the value ‘trailing’, remove
|    all SPACEs or TABs at end of line.
| 
| 6. ‘tab-width’ or more SPACEs after TAB.
|    If ‘whitespace-style’ includes the value ‘space-after-tab’:
|    replace SPACEs by TABs, if ‘indent-tabs-mode’ is non-nil;
|    otherwise, replace TABs by SPACEs.
|    If ‘whitespace-style’ includes the value
|    ‘space-after-tab::tab’, replace SPACEs by TABs.
|    If ‘whitespace-style’ includes the value
|    ‘space-after-tab::space’, replace TABs by SPACEs.
| 
| See ‘whitespace-style’, ‘indent-tabs-mode’ and ‘tab-width’ for
| documentation.
`----

Best, Arash



reply via email to

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