dev: merging from master:

This commit is contained in:
Matt Nish-Lapidus 2024-09-07 10:06:34 -04:00
commit 9cc792dd3a
8 changed files with 119 additions and 34 deletions

38
bin/doom.ps1 Normal file
View file

@ -0,0 +1,38 @@
# bin/doom.ps1
if (!(Get-Command -Erroraction silentlycontinue emacs.exe)) {
echo "Couldn't find emacs.exe in your PATH."
exit 1
}
$doom = "$PSScriptRoot/doom"
$emacs = if ($env:EMACS) { $env:EMACS } else { (Get-Command emacs.exe).Path }
$emacsargs = "-q", "--no-site-file", "--batch"
$oldemacsdir = $env:EMACSDIR
try {
$env:EMACSDIR = if (-not $env:EMACSDIR) { (get-item $PSScriptRoot).parent.FullName } else { $env:EMACSDIR }
$env:__DOOMSH = if (-not $env:__DOOMSH) { "ps1" } else { $env:__DOOMSH }
$env:__DOOMPID = if (-not $env:__DOOMPID) { $PID } else { $env:__DOOMPID }
$env:__DOOMSTEP = if (-not $env:__DOOMSTEP) { 0 } else { $env:__DOOMSTEP }
$cols = (Get-Host).UI.RawUI.WindowSize.Width
$lines = (Get-Host).UI.RawUI.WindowSize.Height
$env:__DOOMGEOM = if (-not $env:__DOOMGEOM) { "$cols`x$lines" } else { $env:__DOOMGEOM }
# $env:__DOOMGPIPE = if (-not $env:__DOOMGPIPE) { $env:__DOOMPIPE } else { $env:__DOOMGPIPE }
# $env:__DOOMPIPE = ""
& $emacs $emacsargs --load "$doom" -- --no-color $args
$exit = $LASTEXITCODE
} finally {
$env:EMACSDIR = $oldemacsdir
Remove-Item Env:\__DOOMSH
Remove-Item Env:\__DOOMPID
Remove-Item Env:\__DOOMSTEP
Remove-Item Env:\__DOOMGEOM
}
if ($exit -eq 254) {
& pwsh "$($env:temp)\doom.$($env:__DOOMPID).$($env:__DOOMSTEP).ps1" $PSCommandPath $args
$exit = $LASTEXITCODE
}
exit $exit

View file

@ -57,6 +57,7 @@ if [ ! -f "$EMACSDIR/early-init.el" ]; then
fi >&2
# Some state that Doom's CLI framework needs to know about the terminal. Read
# the comments at the top of bin/doom for explanations.
export __DOOMSH="${__DOOMSH:-sh}"
export __DOOMPID="${__DOOMPID:-$$}"
export __DOOMSTEP="${__DOOMSTEP:-0}"
export __DOOMGEOM="${__DOOMGEOM:-$(tput cols 2>/dev/null)x$(tput lines 2>/dev/null)}"

View file

@ -1121,19 +1121,27 @@ Emacs' batch library lacks an implementation of the exec system call."
(error "__DOOMSTEP envvar missing; extended `exit!' functionality will not work"))
(let* ((pid (doom-cli-context-pid context))
(step (doom-cli-context-step context))
(shtype (or (getenv "__DOOMSH") "sh"))
(context-file (format (doom-path temporary-file-directory "doom.%s.%s.context") pid step))
(script-file (format (doom-path temporary-file-directory "doom.%s.%s.sh") pid step))
(script-file (format (doom-path temporary-file-directory "doom.%s.%s.%s") pid step shtype))
(command (if (listp args) (combine-and-quote-strings (remq nil args)) args))
(persistent-files
(combine-and-quote-strings (delq nil (list script-file context-file))))
(persisted-env
(cl-remove-if-not
#'cdr (append
`(("DOOMPROFILE" . ,(ignore-errors (doom-profile->id doom-profile)))
("EMACSDIR" . ,doom-emacs-dir)
("DOOMDIR" . ,doom-user-dir)
("DEBUG" . ,(if init-file-debug "1"))
("__DOOMPID" . ,(number-to-string (doom-cli-context-pid context)))
("__DOOMSTEP" . ,(number-to-string (doom-cli-context-step context)))
("__DOOMCONTEXT" . ,context-file))
(save-match-data
(cl-loop with initial-env = (get 'process-environment 'initial-value)
for env in (seq-difference process-environment initial-env)
if (string-match "^\\([a-zA-Z0-9_][^=]+\\)=\\(.+\\)$" env)
collect (format "%s=%s"
(match-string 1 env)
(shell-quote-argument (match-string 2 env)))))))
collect (cons (match-string 1 env) (match-string 2 env))))))))
(cl-incf (doom-cli-context-step context))
(with-file-modes #o600
(doom-log "restart: writing context to %s" context-file)
@ -1154,25 +1162,35 @@ Emacs' batch library lacks an implementation of the exec system call."
newcontext))
(doom-log "restart: writing post-script to %s" script-file)
(doom-file-write
script-file `("#!/usr/bin/env sh\n"
script-file
(pcase-exhaustive shtype
("sh" `(,(if (featurep :system 'android)
"#!/bin/sh\n"
"#!/usr/bin/env sh\n")
"trap _doomcleanup EXIT\n"
"_doomcleanup() {\n rm -f " ,persistent-files "\n}\n"
"_doomrun() {\n " ,command "\n}\n"
,(string-join persisted-env " \\\n")
,(cl-loop for (envvar . val)
in `(("DOOMPROFILE" . ,(ignore-errors (doom-profile->id doom-profile)))
("EMACSDIR" . ,doom-emacs-dir)
("DOOMDIR" . ,doom-user-dir)
("DEBUG" . ,(if init-file-debug "1"))
("__DOOMSTEP" . ,(number-to-string (doom-cli-context-step context)))
("__DOOMCONTEXT" . ,context-file))
if val
concat (format "%s=%s \\\n" envvar (shell-quote-argument val)))
,(cl-loop for (var . val) in persisted-env
concat (format "%s=%s \\\n" var (shell-quote-argument val)))
,(format "PATH=\"%s%s$PATH\" \\\n"
(doom-path doom-emacs-dir "bin")
path-separator)
"_doomrun \"$@\"\n")))
(doom-log "_doomrun: %s %s" (string-join persisted-env " ") command)
"_doomrun \"$@\"\n"))
("ps1" `("try {\n"
,(cl-loop for (var . val) in persisted-env
concat (format " $__%s = $env:%s; $env:%s = %S\n "
var var var val))
,command
"\n} finally {\n"
,(cl-loop for file in persistent-files
concat (format " Remove-Item -Path %S\n " file))
,(cl-loop for (var . val) in envvars
concat (format " $env:%s = $__%s\n " var var))
"\n}")))))
(doom-log "_doomrun: %s %s"
(cl-loop for (var . val) in persisted-env
concat (format "%s=%s \\\n" var (shell-quote-argument val)))
command)
(doom-log "_doomcleanup: %s" persistent-files)
;; Error code 254 is special: it indicates to the caller that the
;; post-script should be executed after this session ends. It's up to
@ -1268,7 +1286,11 @@ Arguments don't have to be switches either."
ARGS are options passed to less. If DOOMPAGER is set, ARGS are ignored."
(let ((pager (or doom-cli-pager (getenv "DOOMPAGER"))))
(cond ((null (or pager (executable-find "less")))
(cond ((equal (getenv "__DOOMSH") "ps1")
;; Pager isn't supported in powershell
(doom-cli--exit 0 context))
((null (or pager (executable-find "less")))
(user-error "No pager set or available")
(doom-cli--exit 1 context))

View file

@ -589,7 +589,9 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
(setq doom-theme theme)
(put 'doom-theme 'previous-themes (or last-themes 'none))
;; DEPRECATED Hook into `enable-theme-functions' when we target 29
(doom-run-hooks 'doom-load-theme-hook))))))
(doom-run-hooks 'doom-load-theme-hook)
(setf (alist-get 'foreground-color default-frame-alist) (face-foreground 'default nil t)
(alist-get 'background-color default-frame-alist) (face-background 'default nil t)))))))
;;

View file

@ -121,7 +121,8 @@
('darwin '(macos bsd))
((or 'cygwin 'windows-nt 'ms-dos) '(windows))
((or 'gnu 'gnu/linux) '(linux))
((or 'gnu/kfreebsd 'berkeley-unix) '(linux bsd)))
((or 'gnu/kfreebsd 'berkeley-unix) '(linux bsd))
('android '(android)))
"A list of symbols denoting available features in the active Doom profile.")
;; Convenience aliases for internal use only (may be removed later).

View file

@ -74,7 +74,12 @@ And jumps to your `doom!' block."
,on-failure))
nil 'local))))))
(defvar doom-reload-command "%s sync -B -e"
(defvar doom-reload-command
(format "%s sync -B -e"
;; /usr/bin/env doesn't exist on Android
(if (featurep :system 'android)
"sh %%s"
"%%s"))
"Command that `doom/reload' runs.")
;;;###autoload
(defun doom/reload ()
@ -138,7 +143,12 @@ imported into Emacs."
(doom-load-envvars-file doom-env-file)
(message "Reloaded %S" (abbreviate-file-name doom-env-file))))))
(defvar doom-upgrade-command "%s upgrade -B --force"
(defvar doom-upgrade-command
(format "%s upgrade -B --force"
;; /usr/bin/env doesn't exist on Android
(if (featurep :system 'android)
"sh %%s"
"%%s"))
"Command that `doom/upgrade' runs.")
;;;###autoload
(defun doom/upgrade ()

View file

@ -128,7 +128,18 @@ If no viewer is found, `latex-preview-pane-mode' is used.")
:desc "View" "v" #'TeX-view
:desc "Compile" "c" #'+latex/compile
:desc "Run all" "a" #'TeX-command-run-all
:desc "Run a command" "m" #'TeX-command-master))
:desc "Run a command" "m" #'TeX-command-master)
;; HACK: The standard LaTeXMk command uses `TeX-run-format', which doesn't
;; trigger `TeX-after-compilation-finished-functions', so swap it out for
;; `TeX-run-TeX', which does.
(defadvice! +latex--run-after-compilation-finished-functions-a (&rest args)
:after #'TeX-TeX-sentinel
(unless (TeX-error-report-has-errors-p)
(run-hook-with-args 'TeX-after-compilation-finished-functions
(with-current-buffer TeX-command-buffer
(expand-file-name
(TeX-active-master (TeX-output-extension))))))))
(use-package! tex-fold

View file

@ -16,7 +16,7 @@ non-nil, the mode will not be activated."
(use-package! highlight-indent-guides
:hook ((prog-mode text-mode conf-mode) . +indent-guides-init-maybe-h)
:init
(setq highlight-indent-guides-method (if (display-graphic-p) 'bitmap 'character)
(setq highlight-indent-guides-method 'character
highlight-indent-guides-bitmap-function #'highlight-indent-guides--bitmap-line)
(defun +indent-guides-init-maybe-h ()