Skip to content

VlachJosef/println-debugger

Repository files navigation

println-debugger

Quick generating of println expressions in Emacs Lisp, Scala, Javascript, Typescript and Rust from kill-ring entries.

Usage

When run, println-debugger generates println expression(s) from entries in kill-ring. Each set of expressions is highlighted with an overlay. This overlay defines a keymap property with following commands:

  • C-c C-c - println-debugger-commit - remove overlay and println expressions will become unmanaged by println-debugger.
  • C-M-n - println-debugger-increase - take next entry from kill-ring and generates new println expression.
  • C-M-p - println-debugger-decrease - remove last println expression.
  • C-M-r - println-debugger-reverse - reverse order of generated println expressions.
  • C-M-s - println-debugger-show-identifier - show enclosing defun's name as part of println expression.
  • C-M-m - println-debugger-multiline - put all println expressions to a single line.
  • C-M-a - println-debugger-align - align all println expressions for nicer output.
  • C-M-x - println-debugger-literal-or-identifier - toggle between following println modes:
    • println("a " + a)
    • println("a")
    • println(a)
  • C-M-c - println-debugger-foreach - generates foreach loop (make sure that current kill-ring item refers to a collection type). Example foreach usage.
  • C-M-o - println-debugger-stamp - generate stamp saying "HeRe 111" which will get increased with every use. Order is a global variable. Example stamp usage.
  • C-M-i - println-debugger-reset - reset counter used by println-debugger-stamp to 1.
  • C-M-k - println-debugger-ignore - remove println expression under the cursor and put its killed-text into local ignore list.
  • C-M-d - println-debugger-delete-at-point - remove all println expressions in current set.

Example config with autoload

Binding C-M-n to println-debugger by remapping from original command forward-list.

(use-package println-debugger
  :load-path "~/println-debugger/"
  :commands println-debugger
  :bind (:map emacs-lisp-mode-map
              ([remap forward-list] . println-debugger)))

(use-package println-debugger-emacs-lisp
  :after println-debugger
  :load-path "~/println-debugger/")

(use-package println-debugger-scala
  :after println-debugger
  :load-path "~/println-debugger/")

(with-eval-after-load 'scala-ts-mode
  (keymap-set scala-ts-mode-map "<remap> <forward-list>" #'println-debugger))

(use-package println-debugger-rust
  :after println-debugger
  :load-path "~/println-debugger/")

(with-eval-after-load 'rust-ts-mode
  (keymap-set rust-ts-mode-map "<remap> <forward-list>" #'println-debugger))

(use-package println-debugger-javascript
  :after println-debugger
  :load-path "~/println-debugger/")

(with-eval-after-load 'typescript-ts-mode
    (keymap-set typescript-ts-mode-map "<remap> <forward-list>" #'println-debugger)
    (keymap-set tsx-ts-mode-map "<remap> <forward-list>" #'println-debugger))

Screencasts

Print item names with their values

println-debugger in action

Print unique stamps

println-debugger in action

Print foreach loop

println-debugger in action

Development

Running tests

  1. Open file println-debugger-tests.el M-x find-file test/println-debugger-tests.el RET

  2. Eval content of buffer println-debugger-tests.el M-x eval-buffer RET

  3. Run all tests by M-x ert RET t RET

About

Quick way for generating println statements

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published