Bubble up reimplementation of TeX-insert-braces

master
Jacopo De Simoi 8 years ago
parent ba677ebfc4
commit 7daf87d64e
  1. 2
      .org-id-locations
  2. 71
      global.org

File diff suppressed because one or more lines are too long

@ -633,7 +633,7 @@
*** Specialty functions
This function adds a pair of delimiters or surrounds the active region
with the given delimiters.
**** TODO it breaks when there is no mark
TODO it breaks when there is no mark
#+BEGIN_SRC emacs-lisp
(defun add-delimiter (delim-begin delim-end r-begin r-end)
"Add the pair of delimiters given in delim at the ends of the
@ -649,6 +649,41 @@
(insert delim-end))
(insert delim-begin))))
#+END_SRC
This reimplements =TeX-insert-braces= to work with negative argument
#+BEGIN_SRC emacs-lisp
(defun TeX-insert-braces (arg)
"Make a pair of braces around next ARG sexps and leave point inside.
No argument is equivalent to zero: just insert braces and leave point
between.
If there is an active region, ARG will be ignored, braces will be
inserted around the region, and point will be left after the
closing brace."
(interactive "P")
(if (TeX-active-mark)
(progn
(if (< (point) (mark))
(exchange-point-and-mark))
(insert TeX-grcl)
(save-excursion
(goto-char (mark))
(insert TeX-grop)))
(if (and arg (< arg 0))
(progn
(save-excursion
(backward-sexp (prefix-numeric-value (- 0 arg)))
(insert TeX-grop))
(insert TeX-grcl))
(insert TeX-grop)
(save-excursion
(if arg (forward-sexp (prefix-numeric-value arg)))
(insert TeX-grcl)))))
(defun TeX-back-insert-braces (arg)
(interactive "P")
(if arg (TeX-insert-braces (- 0 arg))
(insert TeX-grcl)))
#+END_SRC
*** TODO Leftovers
#+BEGIN_SRC emacs-lisp
(setq TeX-fold-ellipsis " …")
@ -755,40 +790,6 @@
(define-key LaTeX-mode-map (kbd "<prior>") (lambda() (interactive) (message "Command disabled")))
))
;; this reimplements TeX-insert-braces to work with negative argument
(defun TeX-insert-braces (arg)
"Make a pair of braces around next ARG sexps and leave point inside.
No argument is equivalent to zero: just insert braces and leave point
between.
If there is an active region, ARG will be ignored, braces will be
inserted around the region, and point will be left after the
closing brace."
(interactive "P")
(if (TeX-active-mark)
(progn
(if (< (point) (mark))
(exchange-point-and-mark))
(insert TeX-grcl)
(save-excursion
(goto-char (mark))
(insert TeX-grop)))
(if (and arg (< arg 0))
(progn
(save-excursion
(backward-sexp (prefix-numeric-value (- 0 arg)))
(insert TeX-grop))
(insert TeX-grcl))
(insert TeX-grop)
(save-excursion
(if arg (forward-sexp (prefix-numeric-value arg)))
(insert TeX-grcl)))))
(defun TeX-back-insert-braces (arg)
(interactive "P")
(if arg (TeX-insert-braces (- 0 arg))
(insert TeX-grcl)))
(defun insert-char-with-padding (arg)
(interactive "*P")
(if (string= (string (preceding-char)) " ") ()

Loading…
Cancel
Save