Fix some stuff from the last commit

This commit is contained in:
Alexander Rosenberg 2024-10-05 02:55:22 -07:00
parent 93ed2b9e39
commit 046ba351ce
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

24
init.el
View File

@ -919,33 +919,29 @@ COMMAND and COMINT are like `compile'."
(regexp-opt '("gschema" "gresource" "ui")) "\\'") . nxml-mode)))
;; Bibtex (built in)
(use-package bibtex
:ensure nil
:defer nil
:config
(require 'bibtex)
(defun my/bibtex-in-entry-p (&optional exclude-braces)
"Return t is point is inside a BibTeX entry.
When EXCLUDE-BRACES is non-nil, don't count the first and last brace of the
entry as in the entry. That is, if the point is on the first { or last } of the
entry, return nil."
(save-excursion
;; go to top level and check if the character at point is {
(when (and (not exclude-braces) (= ?{ (char-after)))
(when (and exclude-braces (= ?\} (char-after)))
(forward-char))
;; go to top level and check if the character at point is {
(let ((start-pos (point))
(last-valid (point)))
(condition-case _
(while t
(up-list 1 t t)
(backward-up-list 1 t t)
(setq last-valid (point)))
(error
(and
(= ?\} (char-before last-valid))
(= ?\{ (char-after last-valid))
;; up-point moves to the char after the last brace, so if the point
;; started there, we aren't in the entry
(not (= start-pos last-valid))
(or (not exclude-braces)
(not (= start-pos (1- last-valid))))))))))
(not (= start-pos last-valid)))))))))
(defvar my/bibtex-indent-width 4
"Width to indent for `my/bibtex-calculate-indentation'.")
(defun my/bibtex-calculate-indentation ()
@ -965,7 +961,7 @@ entry, return nil."
(interactive)
(save-excursion
(beginning-of-line)
(when (my/bibtex-empty-line-p)
(when (looking-at (rx (+ blank)))
(delete-region (point) (match-end 0)))
(indent-to (my/bibtex-calculate-indentation)))
(when (looking-at (rx (+ blank) eol))
@ -986,12 +982,14 @@ otherwise, call `bibtex-find-text'."
(evil-append 1)
(evil-insert 1)))
(defun my/-bibtex-setup-indent ()
(setq-local indent-line-function 'my/bibtex-indent-line))
"Set up `bibtex-mode' indentation stuff."
(setq-local indent-line-function 'my/bibtex-indent-line
electric-indent-chars '(?\n ?\{ ?\} ?,)))
(add-hook 'bibtex-mode-hook 'my/-bibtex-setup-indent)
(define-key bibtex-mode-map (kbd "RET") 'newline-and-indent)
(define-key bibtex-mode-map (kbd "TAB") 'my/bibtex-indent-or-find-text)
(evil-define-key 'normal bibtex-mode-map
(kbd "TAB") 'my/bibtex-indent-or-find-text-and-insert))
(kbd "TAB") 'my/bibtex-indent-or-find-text-and-insert)
;; AUCTeX
(use-package auctex