[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt 20fa6a76e0 150/323: Clear out unset or nil va
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt 20fa6a76e0 150/323: Clear out unset or nil variables after setting them via defaults |
Date: |
Thu, 9 Mar 2023 10:58:25 -0500 (EST) |
branch: externals/beardbolt
commit 20fa6a76e0463075e180a20f133b60319d2984fe
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Jay Kamat <jaygkamat@gmail.com>
Clear out unset or nil variables after setting them via defaults
---
README.org | 8 ++++----
rmsbolt.el | 30 ++++++++++++++++++++++++++++--
2 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/README.org b/README.org
index 9fbdcb2417..57a0222f85 100644
--- a/README.org
+++ b/README.org
@@ -77,10 +77,10 @@ compiler and rmsbolt options simply by editing a local
variable block. The
starter files have this block with some common settings:
#+BEGIN_SRC c
-// Local Variables:
-// rmsbolt-command: "gcc -O0"
-// rmsbolt-disassemble: nil
-// End:
+ // Local Variables:
+ // rmsbolt-command: "gcc -O0"
+ // rmsbolt-disassemble: nil
+ // End:
#+END_SRC
*Note*:
[[https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables][the
Local Variable block must be 3000 characters from the end of the
diff --git a/rmsbolt.el b/rmsbolt.el
index 6bf8025b4e..8e50fd3b84 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -226,6 +226,12 @@ Please DO NOT modify this blindly, as this directory will
get deleted on Emacs e
(defvar-local rmsbolt--real-src-file nil
"If set, the real filename that we compiled from, probably due to a copy
from this file.")
+;; FIXME should we be unbinding the list here, or is setting nil good enough.
+(defvar-local rmsbolt--default-variables nil
+ "A list of the buffer-local variables we filled in with defaults.
+Useful for determining if the user overrode things like `rmsbolt-command'.
+
+This list of variables will automatically be restored to nil.")
;;;; Variable-like funcs
(defun rmsbolt-output-filename (src-buffer &optional asm)
@@ -355,6 +361,7 @@ Generally not useful with the sole exception of the emacs
lisp disassembler.
This function is responsible for calling `rmsbolt--handle-finish-compile'
Please be careful when setting this, as it bypasses most logic and is
generally not useful."))
+;;;; Helper Functions
(defmacro rmsbolt--with-files (src-buffer &rest body)
"Execute BODY with `src-filename' and `output-filename' defined.
Args taken from SRC-BUFFER.
@@ -366,7 +373,13 @@ Return value is quoted for passing to the shell."
(rmsbolt-output-filename ,src-buffer))))
,@body))
-;;;; Compile Commands
+(defmacro rmsbolt--set-local (var val)
+ "Set unquoted variable VAR to value VAL in current buffer."
+ (declare (debug (symbolp form)))
+ `(set (make-local-variable ,var) ,val))
+
+;;;; Language Functions
+;;;;; Compile Commands
(cl-defun rmsbolt--c-compile-cmd (&key src-buffer)
"Process a compile command for gcc/clang."
@@ -586,7 +599,7 @@ https://github.com/derickr/vld"
(rmsbolt--handle-finish-compile src-buffer nil :override-buffer
(current-buffer)))))
-;;;; Hidden Function Definitions
+;;;;; Hidden Function Definitions
(defvar rmsbolt--hidden-func-c
(rx bol (or (and "__" (0+ any))
@@ -1046,6 +1059,12 @@ Argument OVERRIDE-BUFFER use this buffer instead of
reading from the output file
(default-directory (buffer-local-value 'default-directory buffer))
(src-buffer (buffer-local-value 'rmsbolt-src-buffer buffer)))
+ ;; Clear out default-set variables
+ (with-current-buffer src-buffer
+ (dolist (var rmsbolt--default-variables)
+ (rmsbolt--set-local var nil))
+ (setq-local rmsbolt--default-variables nil))
+
(with-current-buffer (get-buffer-create rmsbolt-output-buffer)
;; Store src buffer value for later linking
(cond ((not compilation-fail)
@@ -1133,6 +1152,11 @@ Argument OVERRIDE-BUFFER use this buffer instead of
reading from the output file
(dir rmsbolt-default-directory)
(force-disass (not (rmsbolt-l-supports-asm lang)))
(force-asm (not (rmsbolt-l-supports-disass lang))))
+ ;; If this is non-nil, most likely we are running two compiles at once.
+ ;; This is not exactly ideal, as it causes a race condition.
+ (when rmsbolt--default-variables
+ (message "It looks like RMSbolt state wasn't cleaned up properly.
+Are you running two compilations at the same time?"))
(when (and force-disass force-asm)
(error "No disassemble method found for this langauge, please double
check spec"))
(when force-disass
@@ -1140,12 +1164,14 @@ Argument OVERRIDE-BUFFER use this buffer instead of
reading from the output file
(when force-asm
(setq-local rmsbolt-disassemble nil))
(when (not dir)
+ (add-to-list 'rmsbolt--default-variables 'rmsbolt-default-directory)
(setq-local rmsbolt-default-directory
(let ((new-dir (rmsbolt-l-default-directory lang)))
(pcase new-dir
((pred functionp) (funcall new-dir src-buffer))
(_ new-dir)))))
(when (not cmd)
+ (add-to-list 'rmsbolt--default-variables 'rmsbolt-command)
(setq-local rmsbolt-command
(let ((new-cmd (rmsbolt-l-compile-cmd lang)))
(pcase new-cmd
- [elpa] externals/beardbolt e403331350 322/323: * beardbolt.el (bb--synch-relation-overlays): Fix bug., (continued)
- [elpa] externals/beardbolt e403331350 322/323: * beardbolt.el (bb--synch-relation-overlays): Fix bug., ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 4a6f289c94 002/323: Add very basic compilation of c files, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ac893146e3 019/323: Force dissasembly if we don't support asm, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt f30a05624d 051/323: Add support for parsing .file directives, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 865d5a8c1a 111/323: Clean up CI config, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 7f61815c17 121/323: Try to fix bytecode issues, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt e517cd4dbc 142/323: Remove unneeded disass-hidden-funcs overrides, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt f89875215b 128/323: Fix byte-compilation warnings, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt cb0b781e82 143/323: Add rudimentary support for hack/hhvm, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 4f86bae37e 144/323: Add rmsbolt-asm-format for toggling between asm formats., ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 20fa6a76e0 150/323: Clear out unset or nil variables after setting them via defaults,
ELPA Syncer <=
- [elpa] externals/beardbolt fc712fe954 147/323: Fix typo in readme, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 56f8fd2037 148/323: Add additional salespitch, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 0c19afca2d 157/323: Simplify d support, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt f7aab87454 162/323: Fix README link, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 097abb56de 154/323: Fix tests, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 9fb117d6c9 159/323: Add docs for D language, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 1916179672 166/323: Add support for Zig, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 8cf49aeac6 167/323: Add zig starter, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 2a83b76cd9 172/323: Prevent overriding windows when no output window available, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 820211abd4 169/323: Update supported languages list, ELPA Syncer, 2023/03/09