fix(cli): recognize command argument for --pager
--pager incorrectly expected a boolean argument, when it should accept any arbitrary pager command (set to a blank string to disable the pager). Ref: #6526
This commit is contained in:
parent
442d607ec0
commit
af4c18e283
2 changed files with 26 additions and 22 deletions
4
bin/doom
4
bin/doom
|
@ -179,7 +179,7 @@ SEE ALSO:
|
||||||
(debug? ("-D" "--debug") "Enable verbose output")
|
(debug? ("-D" "--debug") "Enable verbose output")
|
||||||
(doomdir ("--doomdir" dir) "Use Doom config living in `DIR' (e.g. ~/.doom.d)")
|
(doomdir ("--doomdir" dir) "Use Doom config living in `DIR' (e.g. ~/.doom.d)")
|
||||||
(emacsdir ("--emacsdir" dir) "Use Doom install living in `DIR' (e.g. ~/.emacs.d)")
|
(emacsdir ("--emacsdir" dir) "Use Doom install living in `DIR' (e.g. ~/.emacs.d)")
|
||||||
(pager ("--pager" bool) "Pager command to use for large output")
|
(pager ("--pager" cmd) "Pager command to use for large output")
|
||||||
;; TODO Implement after v3.0
|
;; TODO Implement after v3.0
|
||||||
;; (profile ("--profile" name) "Use profile named NAME")
|
;; (profile ("--profile" name) "Use profile named NAME")
|
||||||
&flags
|
&flags
|
||||||
|
@ -222,7 +222,7 @@ SEE ALSO:
|
||||||
(exit! :restart))
|
(exit! :restart))
|
||||||
;; But these don't need a restart:
|
;; But these don't need a restart:
|
||||||
(when pager
|
(when pager
|
||||||
(setenv "DOOMPAGER" pager))
|
(setq doom-cli-pager pager))
|
||||||
(when force?
|
(when force?
|
||||||
(setf (doom-cli-context-suppress-prompts-p context) t)
|
(setf (doom-cli-context-suppress-prompts-p context) t)
|
||||||
(doom-log "User requested all prompts be suppressed"))
|
(doom-log "User requested all prompts be suppressed"))
|
||||||
|
|
|
@ -1176,28 +1176,32 @@ Emacs' batch library lacks an implementation of the exec system call."
|
||||||
"Invoke pager on output unconditionally.
|
"Invoke pager on output unconditionally.
|
||||||
|
|
||||||
ARGS are options passed to less. If DOOMPAGER is set, ARGS are ignored."
|
ARGS are options passed to less. If DOOMPAGER is set, ARGS are ignored."
|
||||||
(cond ((null (or doom-cli-pager (executable-find "less")))
|
(let ((pager (or doom-cli-pager (getenv "DOOMPAGER"))))
|
||||||
(user-error "No pager set or available")
|
(cond ((null (or pager (executable-find "less")))
|
||||||
(doom-cli--exit 1 context))
|
(user-error "No pager set or available")
|
||||||
|
(doom-cli--exit 1 context))
|
||||||
|
|
||||||
((doom-cli-context-pipe-p context :out t)
|
((or (doom-cli-context-pipe-p context :out t)
|
||||||
(doom-cli--exit 0 context))
|
(equal pager ""))
|
||||||
|
(doom-cli--exit 0 context))
|
||||||
|
|
||||||
((let ((tmpfile (doom-cli--output-file 'output context))
|
((let ((tmpfile (doom-cli--output-file 'output context))
|
||||||
(coding-system-for-write 'utf-8-auto))
|
(coding-system-for-write 'utf-8-auto))
|
||||||
(make-directory (file-name-directory tmpfile) t)
|
(make-directory (file-name-directory tmpfile) t)
|
||||||
(with-temp-file tmpfile
|
(with-temp-file tmpfile
|
||||||
(insert-buffer-substring (doom-cli-context-stdout context)))
|
(insert-buffer-substring (doom-cli-context-stdout context)))
|
||||||
(set-file-modes tmpfile #o600)
|
(set-file-modes tmpfile #o600)
|
||||||
(doom-cli--restart
|
(doom-cli--restart
|
||||||
(format "${DOOMPAGER:-less %s} <%s; rm -f%s %s"
|
(format "%s <%s; rm -f%s %s"
|
||||||
(combine-and-quote-strings
|
(or pager
|
||||||
(append (if doom-print-backend '("-r")) ; process ANSI codes
|
(format "less %s"
|
||||||
(or (delq nil args) '("+g"))))
|
(combine-and-quote-strings
|
||||||
(shell-quote-argument tmpfile)
|
(append (if doom-print-backend '("-r")) ; process ANSI codes
|
||||||
(if init-file-debug "v" "")
|
(or (delq nil args) '("+g"))))))
|
||||||
(shell-quote-argument tmpfile))
|
(shell-quote-argument tmpfile)
|
||||||
context)))))
|
(if init-file-debug "v" "")
|
||||||
|
(shell-quote-argument tmpfile))
|
||||||
|
context))))))
|
||||||
|
|
||||||
(defun doom-cli--exit-pager-maybe (args context)
|
(defun doom-cli--exit-pager-maybe (args context)
|
||||||
"Invoke pager if stdout is longer than TTY height * `doom-cli-pager-ratio'.
|
"Invoke pager if stdout is longer than TTY height * `doom-cli-pager-ratio'.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue