Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jcs-elpa/msgu
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.1.0
Choose a base ref
...
head repository: jcs-elpa/msgu
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Sep 7, 2022

  1. add sleep/sit

    jcs090218 committed Sep 7, 2022
    Copy the full SHA
    5f1d14d View commit details
  2. docs(CHANGLOG): update

    jcs090218 committed Sep 7, 2022
    Copy the full SHA
    c33976c View commit details
  3. fix(checkdoc): update

    jcs090218 committed Sep 7, 2022
    Copy the full SHA
    a32c979 View commit details

Commits on Sep 8, 2022

  1. Copy the full SHA
    690df6d View commit details
  2. docs(CHANGELOG): update

    jcs090218 committed Sep 8, 2022
    Copy the full SHA
    5ce2762 View commit details
  3. docs(README): update doc

    jcs090218 committed Sep 8, 2022
    Copy the full SHA
    faee1fc View commit details
  4. docs(README): update doc

    jcs090218 committed Sep 8, 2022
    Copy the full SHA
    a606652 View commit details

Commits on Sep 14, 2022

  1. Copy the full SHA
    d856aa2 View commit details

Commits on Oct 8, 2022

  1. Update README.md

    jcs090218 authored Oct 8, 2022
    Copy the full SHA
    3e02b33 View commit details
  2. Update README.md

    jcs090218 authored Oct 8, 2022
    Copy the full SHA
    3151ab5 View commit details

Commits on Oct 23, 2022

  1. Update README.md

    jcs090218 authored Oct 23, 2022
    Copy the full SHA
    4c32c21 View commit details
  2. add autoload

    jcs090218 committed Oct 23, 2022
    Copy the full SHA
    0d95ab8 View commit details

Commits on Dec 4, 2022

  1. Copy the full SHA
    8d4c2b1 View commit details

Commits on Dec 10, 2022

  1. Copy the full SHA
    80244c9 View commit details
  2. Copy the full SHA
    8032c83 View commit details

Commits on Jun 8, 2023

  1. Copy the full SHA
    3d84a9b View commit details

Commits on Jul 31, 2023

  1. Choose

    jcs090218 committed Jul 31, 2023
    Copy the full SHA
    0a6bfed View commit details

Commits on Aug 10, 2023

  1. Copy the full SHA
    9263e5a View commit details

Commits on Sep 4, 2023

  1. build(deps): bump actions/checkout from 3 to 4

    Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
    - [Release notes](https://github.com/actions/checkout/releases)
    - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
    - [Commits](actions/checkout@v3...v4)
    
    ---
    updated-dependencies:
    - dependency-name: actions/checkout
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Sep 4, 2023
    Copy the full SHA
    eda762e View commit details

Commits on Sep 6, 2023

  1. Merge pull request #1 from jcs-elpa/dependabot/github_actions/actions…

    …/checkout-4
    
    build(deps): bump actions/checkout from 3 to 4
    jcs090218 authored Sep 6, 2023
    Copy the full SHA
    b7e9ea7 View commit details

Commits on Dec 11, 2023

  1. Update README.md

    jcs090218 authored Dec 11, 2023
    Copy the full SHA
    a0ff778 View commit details
  2. Update README.md

    jcs090218 authored Dec 11, 2023
    Copy the full SHA
    2413d0e View commit details

Commits on Jan 1, 2024

  1. Copy the full SHA
    912dd81 View commit details

Commits on Jan 20, 2024

  1. chore: Test 29.2

    jcs090218 authored Jan 20, 2024
    Copy the full SHA
    56f2c02 View commit details

Commits on Feb 1, 2024

  1. Rename license without ext

    jcs090218 committed Feb 1, 2024
    Copy the full SHA
    56be334 View commit details

Commits on Mar 27, 2024

  1. ci: Bump Emacs 29.x to 3

    jcs090218 authored Mar 27, 2024
    Copy the full SHA
    80ff29f View commit details

Commits on May 8, 2024

  1. Copy the full SHA
    1b120a1 View commit details

Commits on Jun 5, 2024

  1. fix: msgu current

    jcs090218 committed Jun 5, 2024
    Copy the full SHA
    ca223c9 View commit details
  2. should be one line

    jcs090218 committed Jun 5, 2024
    Copy the full SHA
    f99ca37 View commit details

Commits on Jul 21, 2024

  1. ci: Test Emacs 29.4

    jcs090218 authored Jul 21, 2024
    Copy the full SHA
    ec12bcd View commit details

Commits on Jan 1, 2025

  1. Update copyright year

    jcs090218 committed Jan 1, 2025
    Copy the full SHA
    c7b53f3 View commit details

Commits on Feb 13, 2025

  1. Update .gitignore

    jcs090218 authored Feb 13, 2025
    Copy the full SHA
    61698a0 View commit details

Commits on Feb 24, 2025

  1. Update test.yml

    jcs090218 authored Feb 24, 2025
    Copy the full SHA
    231edb8 View commit details

Commits on Feb 26, 2025

  1. docs: Clean up $ for copy

    jcs090218 authored Feb 26, 2025
    Copy the full SHA
    cf1340f View commit details
Showing with 241 additions and 17 deletions.
  1. +6 −0 .github/dependabot.yml
  2. +21 −7 .github/workflows/test.yml
  3. +3 −0 .gitignore
  4. +2 −1 CHANGELOG.md
  5. +2 −0 Eask
  6. 0 LICENSE.txt → LICENSE
  7. +1 −1 Makefile
  8. +118 −1 README.md
  9. +88 −7 msgu.el
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
28 changes: 21 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -14,27 +14,41 @@ concurrency:
jobs:
test:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
emacs-version:
- 26.3
- 27.2
- 28.1
- snapshot
- 28.2
- 29.4
- 30.1
experimental: [false]
include:
- os: ubuntu-latest
emacs-version: snapshot
experimental: true
- os: macos-latest
emacs-version: snapshot
experimental: true
- os: windows-latest
emacs-version: snapshot
experimental: true
exclude:
- os: macos-latest
emacs-version: 26.3
- os: macos-latest
emacs-version: 27.2

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: jcs090218/setup-emacs@master
with:
version: ${{ matrix.emacs-version }}

- uses: actions/setup-node@v2
with:
node-version: '16'

- uses: emacs-eask/setup-eask@master
with:
version: 'snapshot'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -13,3 +13,6 @@ dist/
# packaging
*-autoloads.el
*-pkg.el

# OS generated
.DS_Store
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
## 0.1.1 (Unreleased)
> Released N/A
* N/A
* Add utility functions `sleep`/`sit` (5f1d14db7695109a12ce30346beb2d5523981c4c)
* Extract current message's format string (690df6d067fd2d79f975d4d34f58e1350e417dc3)

## 0.1.0
> Released Sep 07, 2022
2 changes: 2 additions & 0 deletions Eask
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@

(package-file "msgu.el")

(script "test" "echo \"Error: no test specified\" && exit 1")

(source "gnu")

(depends-on "emacs" "26.1")
File renamed without changes.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -30,4 +30,4 @@ lint:
$(EASK) lint package

clean:
$(EASK) clean-all
$(EASK) clean all
119 changes: 118 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,70 @@
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![JCS-ELPA](https://raw.githubusercontent.com/jcs-emacs/badges/master/elpa/v/msgu.svg)](https://jcs-emacs.github.io/jcs-elpa/#/msgu)
<a href="https://jcs-emacs.github.io/"><img align="right" src="https://raw.githubusercontent.com/jcs-emacs/badges/master/others/built-with/dark.svg" alt="Built with"></a>

# msgu
> Utility functions help output the messages
[![CI](https://github.com/jcs-elpa/msgu/actions/workflows/test.yml/badge.svg)](https://github.com/jcs-elpa/msgu/actions/workflows/test.yml)

## Contribute
## 🔧 Usage

### msgu-silent

Silent a code block.

```elisp
(msgu-silent
(message "This cannot be seen..."))
```

### msgu-unsilent

Unsilent a code block.

```elisp
(msgu-unsilent
(message "This can be seen!"))
```

### msgu-inhibit-log

Display in echo area, but don't output to `*Messages*` buffer.

```elisp
(msgu-inhibit-log
(message "Display message in Echo area!"))
```

### msgu-color `(fmt args)`

Print a message with color.

```elisp
(msgu-color (propertize "red" 'face '(:foreground "red")))
```

### msgu-current `(fmt args)`

Print a message with the last message above.

```elisp
(message "This is last message.") ; set current message
(msgu-current "New message!~") ; output with last message
```

output:

```
This is last message.
New message!~
```

You can `msgu-currnet-format` to adjust string format, default is `"%s\n\n"`.

## 🛠️ Contribute

[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)
[![Elisp styleguide](https://img.shields.io/badge/elisp-style%20guide-purple)](https://github.com/bbatsov/emacs-lisp-style-guide)
@@ -17,3 +75,62 @@ If you would like to contribute to this project, you may either
clone and make pull requests to this repository. Or you can
clone the project and establish your own branch of this tool.
Any methods are welcome!

### 🔬 Development

To run the test locally, you will need the following tools:

- [Eask](https://emacs-eask.github.io/)
- [Make](https://www.gnu.org/software/make/) (optional)

Install all dependencies and development dependencies:

```sh
eask install-deps --dev
```

To test the package's installation:

```sh
eask package
eask install
```

To test compilation:

```sh
eask compile
```

**🪧 The following steps are optional, but we recommend you follow these lint results!**

The built-in `checkdoc` linter:

```sh
eask lint checkdoc
```

The standard `package` linter:

```sh
eask lint package
```

*📝 P.S. For more information, find the Eask manual at https://emacs-eask.github.io/.*

## ⚜️ License

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

See [`LICENSE`](./LICENSE.txt) for details.
95 changes: 88 additions & 7 deletions msgu.el
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
;;; msgu.el --- Utility functions help output the messages -*- lexical-binding: t; -*-

;; Copyright (C) 2022 Shen, Jen-Chieh
;; Copyright (C) 2022-2025 Shen, Jen-Chieh

;; Author: Shen, Jen-Chieh <jcs090218@gmail.com>
;; Maintainer: Shen, Jen-Chieh <jcs090218@gmail.com>
;; URL: https://github.com/jcs-elpa/msgu
;; Version: 0.1.0
;; Package-Requires: ((emacs "24.3"))
;; Package-Requires: ((emacs "26.1"))
;; Keywords: lisp

;; This file is not part of GNU Emacs.
@@ -37,6 +37,13 @@
:group 'convenience
:link '(url-link :tag "Repository" "https://github.com/jcs-elpa/msgu"))

(defcustom msgu-log-max (or (ignore-errors (default-value 'message-log-max))
1000)
"`message-log-max' for unsilencing."
:type 'integer
:group 'msgu)

;;;###autoload
(defmacro msgu-inhibit-log (&rest body)
"Execute BODY without write it to message buffer."
(declare (indent 0) (debug t))
@@ -54,14 +61,88 @@
(defmacro msgu-unsilent (&rest body)
"Execute BODY with ensuring message log."
(declare (indent 0) (debug t))
`(let ((message-log-max 1000)) ,@body))
`(let ((message-log-max msgu-log-max)) ,@body))

;;
;; (@* "Util" )
;;

(defun msgu-2str (obj)
"Convert OBJ to string."
(format "%s" obj))

(defun msgu--count-matches (pattern str)
"Count occurrences of PATTERN in STR.
Like function `s-count-matches' but faster."
(max 0 (1- (length (split-string str pattern)))))

;;
;; (@* "Delay" )
;;

(defcustom msgu-sleep-seconds 0.4
"Default seconds to sleep after calling `msgu-sleep' function."
:type 'number
:group 'msgu)

(defcustom msgu-sit-seconds 100
"Default seconds to sit after calling `msgu-sit' function."
:type 'number
:group 'msgu)

;;;###autoload
(defun msgu-sleep (&optional seconds milliseconds)
"Wrap `sleep-for' function width default SECONDS and MILLISECONDS."
(sleep-for (or seconds msgu-sleep-seconds) milliseconds))

;;;###autoload
(defun msgu-sit (&optional seconds nodisp)
"Wrap `sit-for' function with default SECONDS and NODISP."
(sit-for (or seconds msgu-sit-seconds) nodisp))

;;
;; (@* "Color" )
;;

;; TOPIC: How to preserve color in *Messages* buffer?
;; SOURCE: https://emacs.stackexchange.com/questions/20171/how-to-preserve-color-in-messages-buffer

(defun msgu-color (fmt &rest args)
"Like function `message' but preserve color in the buffer.
Arguments FMT and ARGS are used for format message."
(msgu-inhibit-log (apply 'message fmt args))
(with-current-buffer (messages-buffer)
(save-excursion
(goto-char (point-max))
(let ((inhibit-read-only t))
(insert (apply 'format fmt args))))))

;;
;; (@* "Others" )
;;

(defcustom msgu-currnet-format "%s\n\n"
"String use to format current message."
:type 'string
:group 'msgu)

;;;###autoload
(defun msgu-current (fmt &rest args)
"Log messages with current message on top if available."
(message "%s%s"
(if (current-message) (concat (current-message) "\n\n") "")
(apply #'format fmt args)))
"Log messages with current message on top if available.
Arguments FMT and ARGS are used for format message."
(let* ((msg (current-message))
(one-line (and msg (< (msgu--count-matches "\n" msg) 1))))
(message "%s%s"
(cond (one-line
(msgu-2str msg))
(msg
(format msgu-currnet-format msg))
(t
""))
(apply #'format fmt args))))

(provide 'msgu)
;;; msgu.el ends here