[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt ce91938102 261/323: Simplify management of bb
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt ce91938102 261/323: Simplify management of bb--temp-dir |
Date: |
Thu, 9 Mar 2023 10:58:37 -0500 (EST) |
branch: externals/beardbolt
commit ce9193810255b1f879a7c917977ddcfdb60177d8
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Simplify management of bb--temp-dir
* beardbolt.el (bb--temp-dir): New function.
(bb--gen-temp): Delete.
(bb-output-filename, bb--pony-compile-cmd): use bb--temp-dir.
(bb-starter): Don't use bb--gen-temp
(bb--demangle-command): Use bb--temp-dir
(bb-compile): Don't use bb--gen-temp
---
beardbolt.el | 49 +++++++++++++++++--------------------------------
1 file changed, 17 insertions(+), 32 deletions(-)
diff --git a/beardbolt.el b/beardbolt.el
index 4626242e01..70e30ec4ac 100644
--- a/beardbolt.el
+++ b/beardbolt.el
@@ -239,10 +239,13 @@ may not be cleared to default as variables are usually."
Used to work around inconsistencies in alternative shells.")
(defvar bb--temp-dir nil
- "Temporary directory to use for compilation and other reasons.
+ "Temporary directory to use for compilation and other reasons.")
-Please DO NOT modify this blindly, as this directory will get
-deleted on Emacs exit.")
+(defun bb--temp-dir ()
+ (or (and bb--temp-dir
+ (file-exists-p bb--temp-dir)
+ bb--temp-dir)
+ (setq bb--temp-dir (make-temp-file "beardbolt-bb-" t))))
(defvar bb-dir nil
"The directory which beardbolt is installed to.")
@@ -273,8 +276,8 @@ Outputs assembly file if ASM.
This function does NOT quote the return value for use in inferior shells."
(if (and (not asm)
(buffer-local-value 'bb-disassemble src-buffer))
- (expand-file-name "beardbolt.out" bb--temp-dir)
- (expand-file-name "beardbolt.s" bb--temp-dir)))
+ (expand-file-name "beardbolt.out" (bb--temp-dir))
+ (expand-file-name "beardbolt.s" (bb--temp-dir))))
;;;; Regexes
@@ -376,7 +379,7 @@ the compile command.")
(default-directory
nil
:type 'string
- :documentation "Default directory to run compilation in. By default, use
bb--temp-dir.
+ :documentation "Default directory to run compilation in. By default, use
(bb--temp-dir).
If provided a function, call that function with the source buffer to determine
the default directory.")
(compile-cmd-function
@@ -578,7 +581,7 @@ Use SRC-BUFFER as buffer for local variables."
(cl-defun bb--pony-compile-cmd (&key src-buffer)
"Process a compile command for ponyc."
(let* ((cmd (buffer-local-value 'bb-command src-buffer))
- (dir (expand-file-name "pony/" bb--temp-dir))
+ (dir (expand-file-name "pony/" (bb--temp-dir)))
(_ (make-directory dir t))
;; (base-filename (file-name-sans-extension
;; (file-name-nondirectory
@@ -698,7 +701,7 @@ https://github.com/derickr/vld"
src-buffer
(let* ((cmd (buffer-local-value 'bb-command src-buffer))
(cmd
- (let* ((outdir (expand-file-name "nim-cache" bb--temp-dir)))
+ (let* ((outdir (expand-file-name "nim-cache" (bb--temp-dir))))
(string-join
(list cmd
"--debugger:native"
@@ -724,7 +727,7 @@ https://github.com/derickr/vld"
(cmd (string-join
(list cmd
src-filename
- "--cache-dir" (expand-file-name "zig-cache" bb--temp-dir)
+ "--cache-dir" (expand-file-name "zig-cache"
(bb--temp-dir))
(concat (if disass
"-femit-bin="
"-fno-emit-bin -femit-asm=")
@@ -1570,9 +1573,9 @@ and return it."
#'identity
(list "&&" demangler
"<" (bb-output-filename src-buffer t)
- ">" (expand-file-name "tmp.s" bb--temp-dir)
+ ">" (expand-file-name "tmp.s" (bb--temp-dir))
"&&" "mv"
- (expand-file-name "tmp.s" bb--temp-dir)
+ (expand-file-name "tmp.s" (bb--temp-dir))
(bb-output-filename src-buffer t))
" "))
existing-cmd))
@@ -1614,7 +1617,7 @@ and return it."
(asm-format
(buffer-local-value 'bb-asm-format src-buffer))
(default-directory (or bb-default-directory
- bb--temp-dir)))
+ (bb--temp-dir))))
(run-hooks 'bb-after-parse-hook)
(bb--rainbowize-cleanup)
(when (buffer-local-value 'bb-disassemble src-buffer)
@@ -1678,21 +1681,6 @@ and return it."
map)
"Keymap for function `bb-mode'.")
-;;;; Init commands
-
-(defun bb--gen-temp ()
- "Generate beardbolt temp dir if needed."
- (unless (and bb--temp-dir
- (file-exists-p bb--temp-dir))
- (setq bb--temp-dir
- (make-temp-file "bb-" t))
- (add-hook 'kill-emacs-hook
- (lambda ()
- (when (and (boundp 'bb--temp-dir)
- bb--temp-dir
- (file-directory-p bb--temp-dir))
- (delete-directory bb--temp-dir t))
- (setq bb--temp-dir nil)))))
;;;;; Starter Definitions
@@ -1723,10 +1711,9 @@ and return it."
"Setup new file based on the sample STARTER-FILE-NAME."
(interactive
(list (completing-read "Language: " bb-starter-files nil t)))
- (bb--gen-temp)
(let* ((starter-file-name (cdr (assoc lang-name bb-starter-files)))
(file-name
- (expand-file-name starter-file-name bb--temp-dir))
+ (expand-file-name starter-file-name (bb--temp-dir)))
(exists (file-exists-p file-name))
(src-file-name
(when bb-dir
@@ -1906,9 +1893,7 @@ This mode is enabled in both src and assembly output
buffers."
(not (eq (current-buffer) (get-buffer bb-output-buffer))))
(add-hook 'after-save-hook #'bb--after-save nil t)
(when (eq bb-automatic-recompile t)
- (add-hook 'after-change-functions #'bb--after-change nil t)))
-
- (bb--gen-temp))
+ (add-hook 'after-change-functions #'bb--after-change nil t))))
(t ;; Cleanup
(bb--remove-overlays)
(remove-hook 'after-change-functions #'bb--after-change t)
- [elpa] externals/beardbolt 50cd4c6d0c 234/323: Use setq for `rmsbolt-dir`, (continued)
- [elpa] externals/beardbolt 50cd4c6d0c 234/323: Use setq for `rmsbolt-dir`, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 9c56c62993 247/323: Update texi docs, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 3baf531b55 238/323: Refactor: Move let binding closer to point of usage, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 24ac775643 246/323: Support Nim 1.6.6, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt e634757395 235/323: Remove unneeded lambda, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 3514e6f288 237/323: rmsbolt-compile: Only ask to save the current buffer, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ea22302660 258/323: Delete beardbolt-split.el, doesn't justify separate file, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 7619539a86 243/323: starters/elisp: Fix compiler warning, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt d37371b088 249/323: Fix byte-compilation warnings, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 1873e605ab 256/323: Remove unused test/test-helper.el, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ce91938102 261/323: Simplify management of bb--temp-dir,
ELPA Syncer <=
- [elpa] externals/beardbolt 264b614805 264/323: * beardbolt.el (bb-compile): Better handling of hack-local-variables., ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ed99686703 267/323: Handle TTYs with unknown background color, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 715f132d0e 263/323: Started rewriting. Too many changes to mention., ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 325327bc70 273/323: Use inhibit-modification-hooks when modifying buffer, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 5131185d13 272/323: Add a Makefile, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 9aba82b6cd 271/323: Update starter/test files, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt b6958c3e0a 277/323: * beardbolt.el: preserve-library-functions -> preserve-weak-symbols, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 2a11095c75 281/323: Rethink and simplify asm-processing algorithm, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 7ff619c375 283/323: Add some benchmarks, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 11a19cfa66 282/323: Simplify line correspondence and overlay management, ELPA Syncer, 2023/03/09