Skip to content

Commit 3847f72

Browse files
authored
fix: Print with stdout (#205)
* fix: Print with stdout * docs: update * changelog
1 parent 19f3c01 commit 3847f72

File tree

14 files changed

+94
-48
lines changed

14 files changed

+94
-48
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
3838
* Add `melpazoid` command (#202)
3939
* Add `source` command and its subcommands (#203)
4040
* Add `bump` command (#204)
41+
* fix: Print with stdout (#205)
4142

4243
## 0.8.x
4344
> Released Mar 08, 2023

docs/content/en/Development-API/_index.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,17 +753,33 @@ to display.
753753
2022-04-14 17:31:54 [ERROR] This is ERROR message
754754
```
755755

756+
## 🔍 Function: eask-print (`msg` &rest `args`)
757+
758+
Standard output printing without newline.
759+
760+
```elisp
761+
(eask-println "Print to stdout!")
762+
```
763+
764+
## 🔍 Function: eask-println (`msg` &rest `args`)
765+
766+
Like the function `eask-print` but contains the newline at the end.
767+
768+
```elisp
769+
(eask-println "Print to stdout! (with newline)")
770+
```
771+
756772
## 🔍 Function: eask-msg (`msg` &rest `args`)
757773

758-
Like `message` function but will replace unicodes with color.
774+
Like the `message` function but will replace unicode with color.
759775

760776
```elisp
761777
(eask-msg "Print this message with newline!")
762778
```
763779

764780
## 🔍 Function: eask-write (`msg` &rest `args`)
765781

766-
Like `eask-msg` function but without newline at the end.
782+
Like the `eask-msg` function but without the newline at the end.
767783

768784
```elisp
769785
(eask-write "Print this message without newline...")

docs/content/zh-TW/Development-API/_index.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,22 @@ $ cat /.log/messages.log
743743
2022-04-14 17:31:54 [ERROR] 這是錯誤信息
744744
```
745745

746+
## 🔍 函式: eask-print (`msg` &rest `args`)
747+
748+
標準輸出列印不含換行符。
749+
750+
```elisp
751+
(eask-println "打印到標準輸出!")
752+
```
753+
754+
## 🔍 函式: eask-println (`msg` &rest `args`)
755+
756+
與函數 `esk-print` 類似,但末尾包含換行符。
757+
758+
```elisp
759+
(eask-println "打印到標準輸出! (有換行符)")
760+
```
761+
746762
## 🔍 函式: eask-msg (`msg` &rest `args`)
747763

748764
類似於 `message` 函數,但會用顏色替換 unicode。

lisp/_prepare.el

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ This uses function `locate-dominating-file' to look up directory tree."
11021102
(if (eask-file-try-load "./")
11031103
(eask-msg "✓ Loading Eask file in %s... done!" eask-file)
11041104
(eask-msg "✗ Loading Eask file... missing!"))
1105-
(message ""))
1105+
(eask-msg ""))
11061106
(if (not eask-file)
11071107
(eask-help "core/init")
11081108
(package-activate-all)
@@ -1539,20 +1539,40 @@ character."
15391539
(string (eask--msg-displayable-kwds string)))
15401540
string))
15411541

1542+
(defun eask-princ (object &optional stderr)
1543+
"Like function `princ'; with flag STDERR.
1544+
1545+
For argument OBJECT, please see function `princ' for the detials.
1546+
1547+
If optional argument STDERR is non-nil; use stderr instead."
1548+
(unless inhibit-message
1549+
(princ object (when stderr #'external-debugging-output))))
1550+
1551+
(defun eask-print (msg &rest args)
1552+
"Standard output printing without newline.
1553+
1554+
For arguments MSG and ARGS, please see function `eask--format-paint-kwds' for
1555+
the detials."
1556+
(eask-princ (apply #'eask--format-paint-kwds msg args)))
1557+
1558+
(defun eask-println (msg &rest args)
1559+
"Like the function `eask-print' but contains the newline at the end.
1560+
1561+
For arguments MSG and ARGS, please see function `eask-print' for the detials."
1562+
(apply #'eask-print (concat msg "\n") args))
1563+
15421564
(defun eask-msg (msg &rest args)
1543-
"Like function `message' but replace unicodes with color.
1565+
"Like the function `message' but replace unicode with color.
15441566
15451567
For arguments MSG and ARGS, please see function `eask--format-paint-kwds' for
15461568
the detials."
15471569
(message (apply #'eask--format-paint-kwds msg args)))
15481570

15491571
(defun eask-write (msg &rest args)
1550-
"Like function `eask-msg' but without newline at the end.
1572+
"Like the function `eask-msg' but without newline at the end.
15511573
1552-
For arguments MSG and ARGS, please see function `eask--format-paint-kwds' for
1553-
the detials."
1554-
(unless inhibit-message
1555-
(princ (apply #'eask--format-paint-kwds msg args) 'external-debugging-output)))
1574+
For arguments MSG and ARGS, please see function `eask-msg' for the detials."
1575+
(eask-princ (apply #'eask--format-paint-kwds msg args) t))
15561576

15571577
(defun eask-report (&rest args)
15581578
"Report error/warning depends on strict flag.

lisp/core/archives.el

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
(url (cdr archive))
2525
(priority (assoc name package-archive-priorities))
2626
(priority (cdr priority)))
27-
(message (concat " %-" eask--length-name "s %-" eask--length-url "s %-" eask--length-priority "s")
28-
name (eask-2url url) (or priority 0))))
27+
(eask-println
28+
(concat " %-" eask--length-name "s %-" eask--length-url "s %-" eask--length-priority "s")
29+
name (eask-2url url) (or priority 0))))
2930

3031
(defun eask--print-archive-alist (alist)
3132
"Print the archvie ALIST."
@@ -43,14 +44,12 @@
4344
(eask-info "Available archives:")
4445
(eask-msg "")
4546
(eask--print-archive-alist eask-source-mapping)
46-
(eask-msg "")
4747
(eask-info "(Total of %s archive%s available)" (length eask-source-mapping)
4848
(eask--sinr eask-source-mapping "" "s")))
4949
(package-archives
5050
(eask-info "In used archives:")
5151
(eask-msg "")
5252
(eask--print-archive-alist package-archives)
53-
(eask-msg "")
5453
(eask-info "(Total of %s archive%s listed)" (length package-archives)
5554
(eask--sinr package-archives "" "s")))
5655
(t

lisp/core/cat.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
(let* ((line (buffer-substring (line-beginning-position) (line-end-position)))
4747
(line (if ansi-inhibit-ansi line (e2ansi-string-to-ansi line))))
4848
(if (eask-number-p)
49-
(message (concat "%" offset "d %s") line-no line)
50-
(message "%s" line)))
49+
(eask-println (concat "%" offset "d %s") line-no line)
50+
(eask-println "%s" line)))
5151
(forward-line 1)
5252
(cl-incf line-no)))))
5353
(eask-info "(No files match wildcard: %s)"

lisp/core/exec-path.el

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
(defun eask--print-exec-path (path)
2020
"Print out the PATH."
21-
(message "%s" path))
21+
(eask-println "%s" path))
2222

2323
(eask-start
2424
(eask-pkg-init)
@@ -30,7 +30,6 @@
3030
(mapc #'eask--print-exec-path exec-path)
3131
(if (zerop (length exec-path))
3232
(eask-info "(No exec-path found)")
33-
(eask-msg "")
3433
(eask-info "(Total of %s exec-path)" (length exec-path)))))
3534

3635
;;; core/exec-path.el ends here

lisp/core/files.el

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
(defun eask--print-filename (filename)
1818
"Print out the FILENAME."
19-
(message "%s" filename))
19+
(eask-println "%s" filename))
2020

2121
(eask-start
2222
(let* ((patterns (eask-args))
@@ -26,7 +26,6 @@
2626
(mapc #'eask--print-filename files)
2727
(if (zerop (length files))
2828
(eask-info "(No package files found)")
29-
(eask-msg "")
3029
(eask-info "(Total of %s item%s listed)" (length files) (eask--sinr files "" "s")))))
3130

3231
;;; core/files.el ends here

lisp/core/info.el

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
(defun eask--print-deps (title dependencies)
2020
"Print DEPENDENCIES with TITLE identifier."
2121
(when dependencies
22-
(eask-msg "")
23-
(eask-msg title)
22+
(eask-println "")
23+
(eask-println title)
2424
(let* ((names (mapcar #'car dependencies))
2525
(offset (eask-seq-str-max names)))
2626
(setq eask--max-offset (max offset eask--max-offset)
@@ -30,33 +30,33 @@
3030
(target-version (if (= (length target-version) 1)
3131
(nth 0 target-version)
3232
"specified")))
33-
(eask-msg (concat " %-" offset "s (%s)") (car dep) target-version)
33+
(eask-println (concat " %-" offset "s (%s)") (car dep) target-version)
3434
(eask-debug " Recipe: %s" (car dep)))))))
3535

3636
(eask-start
3737
(if eask-package
3838
(progn
39-
(eask-msg "%s (%s) | deps: %s | devDeps: %s"
39+
(eask-println "%s (%s) | deps: %s | devDeps: %s"
4040
(ansi-green (eask-package-name))
4141
(ansi-yellow (eask-package-version))
4242
(ansi-cyan (eask-2str (length eask-depends-on)))
4343
(ansi-cyan (eask-2str (length eask-depends-on-dev))))
4444
(unless (string-empty-p (eask-package-description))
45-
(eask-msg (eask-package-description)))
45+
(eask-println (eask-package-description)))
4646
(when-let* ((url (or (eask-package-desc-url) eask-website-url))
4747
((not (string-empty-p url))))
48-
(eask-msg (ansi-cyan url)))
48+
(eask-println (ansi-cyan url)))
4949
(when-let ((keywords (or (eask-package-desc-keywords) eask-keywords)))
50-
(eask-msg "")
51-
(eask-msg "keywords: %s" (string-join keywords ", ")))
52-
(eask-msg "")
50+
(eask-println "")
51+
(eask-println "keywords: %s" (string-join keywords ", ")))
52+
(eask-println "")
5353
(when eask-package-file
54-
(eask-msg "entry: %s" (eask-root-del eask-package-file)))
55-
(eask-msg "kind: %s" (if (eask-package-multi-p) "tar" "single"))
56-
(eask-msg "")
57-
(eask-msg "dist")
58-
(eask-msg ".total-files: %s" (length (eask-package-files)))
59-
(eask-msg ".unpacked-size: %s" (eask-unpacked-size))
54+
(eask-println "entry: %s" (eask-root-del eask-package-file)))
55+
(eask-println "kind: %s" (if (eask-package-multi-p) "tar" "single"))
56+
(eask-println "")
57+
(eask-println "dist")
58+
(eask-println ".total-files: %s" (length (eask-package-files)))
59+
(eask-println ".unpacked-size: %s" (eask-unpacked-size))
6060
(eask--print-deps "dependencies:" eask-depends-on)
6161
(eask--print-deps "devDependencies:" eask-depends-on-dev))
6262
(eask-info "(Eask file has no package information)")

lisp/core/keywords.el

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
(offset (eask-seq-str-max keywords))
2222
(fmt (concat " %-" (eask-2str offset) "s %s")))
2323
(dolist (keyword keywords)
24-
(eask-msg fmt keyword (cdr (assq keyword finder-known-keywords))))
25-
(eask-msg "")
24+
(eask-println fmt keyword (cdr (assq keyword finder-known-keywords))))
2625
(eask-info "(Total of %s keywords listed)" (length keywords))))
2726

2827
;;; core/keywords.el ends here

0 commit comments

Comments
 (0)