[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/code-cells 7bad8f1cf6 11/36: Speed keys
From: |
ELPA Syncer |
Subject: |
[elpa] externals/code-cells 7bad8f1cf6 11/36: Speed keys |
Date: |
Mon, 28 Feb 2022 15:57:42 -0500 (EST) |
branch: externals/code-cells
commit 7bad8f1cf647e9cfa7fcc36b61ba9eb20d426229
Author: Augusto Stoffel <astoff@users.noreply.github.com>
Commit: Augusto Stoffel <astoff@users.noreply.github.com>
Speed keys
---
README.md | 23 +++++++++++++++++++++++
cells.el | 9 +++++++++
2 files changed, 32 insertions(+)
diff --git a/README.md b/README.md
index e0de5e3668..2921b10a68 100644
--- a/README.md
+++ b/README.md
@@ -175,6 +175,29 @@ Note that since `defhydra` is a macro and wraps the
definition of a
key in an interactive lambda when it is a sexp, we need to use
`cells-do` instead of `cells-command` above.
+### Speed keys
+
+Similarly to org-mode's [speed
keys](https://orgmode.org/manual/Speed-Keys.html),
+the `cells-speed-key` function returns a key definition that only acts
+when the point is at the beginning of a cell boundary. Since this is
+usually not an interesting place to insert text, you can assign short
+keybindings there. A sample configuration is as follows:
+
+``` elisp
+(require 'cells)
+(let ((map cells-mode-map))
+ (define-key map "n" (cells-speed-key 'cells-forward-cell))
+ (define-key map "p" (cells-speed-key 'cells-backward-cell))
+ (define-key map "e" (cells-speed-key (cells-command
'your-favorite-eval-region)))
+ (define-key map (kbd "TAB") (cells-speed-key (lambda ()
+ "Show/hide current cell"
+ (interactive)
+ (outline-minor-mode)
+ (if (outline-invisible-p
(line-end-position))
+ (outline-show-subtree)
+ (outline-hide-subtree))))))
+```
+
### Tweaking the ipynb conversion
If relegating markdown cells to comment blocks offends your literate
diff --git a/cells.el b/cells.el
index e650996ba4..69b47696cc 100644
--- a/cells.el
+++ b/cells.el
@@ -139,6 +139,15 @@ via `pulse-momentary-highlight-region'."
'(pulse-momentary-highlight-region start end))
(funcall ',fun start end)))))
+(defun cells-speed-key (command)
+ "Return a speed key definition, suitable for passing to `define-key'.
+The resulting keybinding will only have any effect when the point
+is at the beginning of a cell heading, in which case it executes
+COMMAND."
+ (list 'menu-item nil command
+ :filter (lambda (d)
+ (if (and (bolp) (looking-at (cells-boundary-regexp))) d))))
+
;;* Minor mode
(defvar-local cells--saved-vars nil
- [elpa] externals/code-cells 1bd650391a 25/36: Update README, (continued)
- [elpa] externals/code-cells 1bd650391a 25/36: Update README, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells 4e973e0122 26/36: Do not assume Emacs has native JSON parsing available, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells 185c33b8b6 27/36: Fix cell movement for files without newline at the end, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells 031f726941 30/36: code-cells-eval: Fix check for a possibly active minor mode, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells ea7799c447 35/36: Release on ELPA, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells 37dce1d908 02/36: Add existing code, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells 30c0359c36 03/36: Simplify motion code, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells aeddd889c2 04/36: Add ipynb support via Jupytext, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells e02bda5b68 09/36: Assorted refinements, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells aefabc4abf 10/36: Comments about ipynb conversion settings, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells 7bad8f1cf6 11/36: Speed keys,
ELPA Syncer <=
- [elpa] externals/code-cells 2dc51b44a3 12/36: Correct outline level before first cell header, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells 9500e07f83 15/36: Fix byte-compilation issue, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells adda62ec82 16/36: Address some packaging issues, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells 67e1479a75 28/36: Add code-cells-mode-maybe, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells f93db2d65c 29/36: Refinement in Commentary section, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells 47305f5439 31/36: Indicate that spaces are allowed before cell boundary marker, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells 68148cfc1f 33/36: Improve cell boundary face, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells f5150fc213 34/36: Update README.md, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells 55e108733a 06/36: Add helper function to call external processes, ELPA Syncer, 2022/02/28
- [elpa] externals/code-cells e6f0230a40 05/36: Notes about the Jupytext integration, ELPA Syncer, 2022/02/28