From 427b70f34795b371ac7621cecb59f4d594febd0f Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Sat, 8 Feb 2025 17:33:34 -0800 Subject: [PATCH] Clean up my/bibtex-in-entry-p --- init.el | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/init.el b/init.el index 66c6c48..1330b74 100644 --- a/init.el +++ b/init.el @@ -1623,21 +1623,10 @@ COMMAND and COMINT are like `compile'." 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 - (when (and exclude-braces (eq ?\} (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 nil - (while t - (backward-up-list 1 t t) - (setq last-valid (point))) - (error - (and - (eq ?\{ (char-after last-valid)) - (or (not exclude-braces) - (not (= start-pos last-valid))))))))) + (cl-destructuring-bind (depth &rest r) (syntax-ppss) + (if (zerop depth) + (and (not exclude-braces) (eql (char-after) ?\{)) + (or (not exclude-braces) (not (eql (char-after) ?\})))))) (defvar my/bibtex-indent-width 4 "Width to indent for `my/bibtex-calculate-indentation'.") (defun my/bibtex-calculate-indentation ()