Function: LaTeX-babel-insert-hyphen
LaTeX-babel-insert-hyphen is an interactive and byte-compiled function
defined in latex.el.
Signature
(LaTeX-babel-insert-hyphen FORCE)
Documentation
Insert a hyphen string.
The string can be either a normal hyphen or the string specified
in LaTeX-babel-hyphen. Whether one or the other is chosen
depends on the value of LaTeX-babel-hyphen-after-hyphen and
the buffer context.
If prefix argument FORCE is non-nil, always insert a regular hyphen.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-babel-insert-hyphen (force)
"Insert a hyphen string.
The string can be either a normal hyphen or the string specified
in `LaTeX-babel-hyphen'. Whether one or the other is chosen
depends on the value of `LaTeX-babel-hyphen-after-hyphen' and
the buffer context.
If prefix argument FORCE is non-nil, always insert a regular hyphen."
(declare (modes LaTeX-mode))
(interactive "*P")
(if (or force
(zerop (length LaTeX-babel-hyphen))
(not LaTeX-babel-hyphen-language)
;; FIXME: It would be nice to check for verbatim constructs in the
;; non-font-locking case, but things like `LaTeX-current-environment'
;; are rather expensive in large buffers.
(and (fboundp 'font-latex-faces-present-p)
(font-latex-faces-present-p '(font-latex-verbatim-face
font-latex-math-face
font-lock-comment-face)))
(texmathp)
(TeX-in-comment))
(call-interactively #'self-insert-command)
(let* ((lang (assoc LaTeX-babel-hyphen-language
LaTeX-babel-hyphen-language-alist))
(hyphen (if lang (nth 1 lang) LaTeX-babel-hyphen))
(h-after-h (if lang (nth 2 lang) LaTeX-babel-hyphen-after-hyphen))
(hyphen-length (length hyphen)))
(cond
;; "= --> -- / -
((string= (buffer-substring (max (- (point) hyphen-length) (point-min))
(point))
hyphen)
(if h-after-h
(progn (delete-char (- hyphen-length))
(insert "--"))
(delete-char (- hyphen-length))
(call-interactively #'self-insert-command)))
;; -- --> [+]-
((string= (buffer-substring (max (- (point) 2) (point-min))
(point))
"--")
(call-interactively #'self-insert-command))
;; - --> "= / [+]-
((eq (char-before) ?-)
(if h-after-h
(progn (delete-char -1)
(insert hyphen))
(call-interactively #'self-insert-command)))
(h-after-h
(call-interactively #'self-insert-command))
(t (insert hyphen))))))