all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Roland Winkler" <winkler@gnu.org>
To: Teemu Likonen <tlikonen@iki.fi>
Cc: 44647@debbugs.gnu.org
Subject: bug#44647: 27.1.50; `bibtex-contline-indentation' doesn't work as file local variable
Date: Sun, 15 Nov 2020 22:09:39 -0600	[thread overview]
Message-ID: <64387.9639.499249.24497@gargle.gargle.HOWL> (raw)
In-Reply-To: <87a6vjmxwy.fsf@iki.fi>

[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 580 bytes --]

On Sat Nov 14 2020 Teemu Likonen wrote:
> This can be fixed by locally let-binding fill-prefix every time in
> the relevant filling function. Patch for that is attached.

Your patch implies that the buffer-local value of fill-prefix is not
what it should be (say, if any other command wants to use it).

How about the rather different patch attached below, partly inspired
by the related comment

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21764#15

which had somehow escaped my attention.  The issues mentioned in
this comment should likewise be fixed by the attached patch.


[-- Attachment #2: bibtex.diff --]
[-- Type: application/octet-stream, Size: 3715 bytes --]

--- bibtex.el~	2020-11-15 21:13:56.440216563 -0600
+++ bibtex.el	2020-11-15 21:28:47.313180062 -0600
@@ -890,7 +890,8 @@
 (defcustom bibtex-comment-start "@Comment"
   "String starting a BibTeX comment."
   :group 'bibtex
-  :type 'string)
+  :type 'string
+  :safe #'stringp)
 
 (defcustom bibtex-add-entry-hook nil
   "List of functions to call when BibTeX entry has been inserted."
@@ -1219,7 +1220,8 @@
   "Offset for BibTeX entries.
 Added to the value of all other variables which determine columns."
   :group 'bibtex
-  :type 'integer)
+  :type 'integer
+  :safe #'integerp)
 
 (defcustom bibtex-field-indentation 2
   "Starting column for the name part in BibTeX fields."
@@ -1232,13 +1234,15 @@
   "Starting column for the text part in BibTeX fields.
 Should be equal to the space needed for the longest name part."
   :group 'bibtex
-  :type 'integer)
+  :type 'integer
+  :safe #'integerp)
 
 (defcustom bibtex-contline-indentation
   (+ bibtex-text-indentation 1)
   "Starting column for continuation lines of BibTeX fields."
   :group 'bibtex
-  :type 'integer)
+  :type 'integer
+  :safe #'integerp)
 
 (defcustom bibtex-align-at-equal-sign nil
   "If non-nil, align fields at equal sign instead of field text.
@@ -2941,7 +2945,7 @@
                                          (1+ (match-beginning 3)) (1- (match-end 3)))))
                                (unless (assoc key crossref-keys)
                                  (push (list key) crossref-keys))))
-                            ;; We have probably have a non-bibtex file.
+                            ;; We probably have a non-bibtex file.
                             ((not (match-beginning bibtex-type-in-head))
                              (throw 'userkey nil))
                             ;; only keys of known entries
@@ -3435,15 +3439,10 @@
                                    bibtex-parse-keys-timeout t
                                    'bibtex-parse-buffers-stealthily)))
   (set (make-local-variable 'paragraph-start) "[ \f\n\t]*$")
-  (set (make-local-variable 'comment-start) bibtex-comment-start)
-  (set (make-local-variable 'comment-start-skip)
-       (concat (regexp-quote bibtex-comment-start) "\\>[ \t]*"))
   (set (make-local-variable 'comment-column) 0)
   (set (make-local-variable 'defun-prompt-regexp) "^[ \t]*@[[:alnum:]]+[ \t]*")
   (set (make-local-variable 'outline-regexp) "[ \t]*@")
   (set (make-local-variable 'fill-paragraph-function) #'bibtex-fill-field)
-  (set (make-local-variable 'fill-prefix)
-       (make-string (+ bibtex-entry-offset bibtex-contline-indentation) ?\s))
   (set (make-local-variable 'font-lock-defaults)
        '(bibtex-font-lock-keywords
          nil t ((?$ . "\"")
@@ -3462,9 +3461,18 @@
   (set (make-local-variable 'syntax-propertize-function)
        (syntax-propertize-via-font-lock
         bibtex-font-lock-syntactic-keywords))
-  (bibtex-set-dialect nil t)
-  ;; Allow `bibtex-dialect' as a file-local variable.
-  (add-hook 'hack-local-variables-hook #'bibtex-set-dialect nil t))
+  (let ((fun (lambda ()
+               (bibtex-set-dialect)
+               (set (make-local-variable 'comment-start) bibtex-comment-start)
+               (set (make-local-variable 'comment-start-skip)
+                    (concat (regexp-quote bibtex-comment-start) "\\>[ \t]*"))
+               (set (make-local-variable 'fill-prefix)
+                    (make-string (+ bibtex-entry-offset
+                                    bibtex-contline-indentation)
+                                 ?\s)))))
+    (if buffer-file-name
+        (add-hook 'hack-local-variables-hook fun nil t)
+      (funcall fun))))
 
 (defun bibtex-entry-alist (dialect)
   "Return entry-alist for DIALECT."

  parent reply	other threads:[~2020-11-16  4:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-14 21:18 bug#44647: 27.1.50; `bibtex-contline-indentation' doesn't work as file local variable Teemu Likonen
2020-11-14 21:27 ` Teemu Likonen
2020-11-15  9:39   ` Teemu Likonen
2020-11-16  4:09   ` Roland Winkler [this message]
2020-11-16 14:05     ` Teemu Likonen
2020-11-16 16:36       ` Roland Winkler
2020-11-16 22:58   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=64387.9639.499249.24497@gargle.gargle.HOWL \
    --to=winkler@gnu.org \
    --cc=44647@debbugs.gnu.org \
    --cc=tlikonen@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.