Skip to content

Commit

Permalink
[emacs] Avoid ‘my-tex-looking-back’ trying to look before buffer start
Browse files Browse the repository at this point in the history
  • Loading branch information
mina86 committed Jun 1, 2024
1 parent df6aa22 commit 7cc959f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions emacs/init.el
Original file line number Diff line number Diff line change
Expand Up @@ -1127,9 +1127,11 @@ instead."
;; Helper for tex-space
(defmacro my-tex-looking-back (regexp len)
"Return non-nil if REGEXP prefixed with \\b matches LEN chars backward."
`(save-excursion
(backward-char ,len)
(looking-at ,(concat "\\b" regexp))))
`(and
(>= (- (point) (point-min)) ,len)
(save-excursion
(backward-char ,len)
(looking-at ,(concat "\\b" regexp)))))

;; insert '~' or '\ ' instead of ' ' in LaTeX when needed
;; Also removes '~' when 2nd space added
Expand Down

0 comments on commit 7cc959f

Please sign in to comment.