Skip to main content
added 181 characters in body
Source Link
Tobias
  • 33.7k
  • 1
  • 38
  • 78

Thanks to arash-esbati's findings it is quite easy to deactivate LaTeX-newline locally within TeX-arg-insert-braces through advices.

Install the following code into your init file and TeX-arg-insert-braces does no longer generate newlines.

;; The following macro should actually be part of package `advice`:
(defmacro advise-flet (flist &rest body)
  "Apply local advices FLIST and execute BODY.
Each advice in FLIST should look like (FUN DEF)
where FUN is a function symbol and DEF is the
locally defined function."
  (declare (indent 1) (debug (sexp body)))
  (append
   `(unwind-protect
    (progn
      ,(cons 'progn
         (cl-loop
          for f in flist
          collect `(advice-add ,(list 'quote (car f)) :override ,(cadr f))
          ))
      ,@body))
   (cl-loop
    for f in flist
    collect `(advice-remove ,(list 'quote (car f)) ,(cadr f))
    ))) 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Begin of customization code:

(defun LaTeX-without-newline (oldfun &rest args)
  "`flet' `LaTeX-newlin'newline' to `ignore' and run `TeX-arg-insert-braces'."
  (advise-flet
      ((LaTeX-newline #'ignore))
    (apply oldfun args)))

(advice-add #'TeX-arg-insert-braces :around #'LaTeX-without-newline)

Thanks to arash-esbati's findings it is quite easy to deactivate LaTeX-newline locally within TeX-arg-insert-braces through advices.

Install the following code into your init file and TeX-arg-insert-braces does no longer generate newlines.

(defmacro advise-flet (flist &rest body)
  "Apply local advices FLIST and execute BODY.
Each advice in FLIST should look like (FUN DEF)
where FUN is a function symbol and DEF is the
locally defined function."
  (declare (indent 1) (debug (sexp body)))
  (append
   `(unwind-protect
    (progn
      ,(cons 'progn
         (cl-loop
          for f in flist
          collect `(advice-add ,(list 'quote (car f)) :override ,(cadr f))
          ))
      ,@body))
   (cl-loop
    for f in flist
    collect `(advice-remove ,(list 'quote (car f)) ,(cadr f))
    )))

(defun LaTeX-without-newline (oldfun &rest args)
  "`flet' `LaTeX-newlin' to `ignore' and run `TeX-arg-insert-braces'."
  (advise-flet
      ((LaTeX-newline #'ignore))
    (apply oldfun args)))

(advice-add #'TeX-arg-insert-braces :around #'LaTeX-without-newline)

Thanks to arash-esbati's findings it is quite easy to deactivate LaTeX-newline locally within TeX-arg-insert-braces through advices.

Install the following code into your init file and TeX-arg-insert-braces does no longer generate newlines.

;; The following macro should actually be part of package `advice`:
(defmacro advise-flet (flist &rest body)
  "Apply local advices FLIST and execute BODY.
Each advice in FLIST should look like (FUN DEF)
where FUN is a function symbol and DEF is the
locally defined function."
  (declare (indent 1) (debug (sexp body)))
  (append
   `(unwind-protect
    (progn
      ,(cons 'progn
         (cl-loop
          for f in flist
          collect `(advice-add ,(list 'quote (car f)) :override ,(cadr f))
          ))
      ,@body))
   (cl-loop
    for f in flist
    collect `(advice-remove ,(list 'quote (car f)) ,(cadr f))
    ))) 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Begin of customization code:

(defun LaTeX-without-newline (oldfun &rest args)
  "`flet' `LaTeX-newline' to `ignore' and run `TeX-arg-insert-braces'."
  (advise-flet
      ((LaTeX-newline #'ignore))
    (apply oldfun args)))

(advice-add #'TeX-arg-insert-braces :around #'LaTeX-without-newline)
Source Link
Tobias
  • 33.7k
  • 1
  • 38
  • 78

Thanks to arash-esbati's findings it is quite easy to deactivate LaTeX-newline locally within TeX-arg-insert-braces through advices.

Install the following code into your init file and TeX-arg-insert-braces does no longer generate newlines.

(defmacro advise-flet (flist &rest body)
  "Apply local advices FLIST and execute BODY.
Each advice in FLIST should look like (FUN DEF)
where FUN is a function symbol and DEF is the
locally defined function."
  (declare (indent 1) (debug (sexp body)))
  (append
   `(unwind-protect
    (progn
      ,(cons 'progn
         (cl-loop
          for f in flist
          collect `(advice-add ,(list 'quote (car f)) :override ,(cadr f))
          ))
      ,@body))
   (cl-loop
    for f in flist
    collect `(advice-remove ,(list 'quote (car f)) ,(cadr f))
    )))

(defun LaTeX-without-newline (oldfun &rest args)
  "`flet' `LaTeX-newlin' to `ignore' and run `TeX-arg-insert-braces'."
  (advise-flet
      ((LaTeX-newline #'ignore))
    (apply oldfun args)))

(advice-add #'TeX-arg-insert-braces :around #'LaTeX-without-newline)