diff options
| author | jao <jao@gnu.org> | 2026-09-28 21:52:40 +0100 |
|---|---|---|
| committer | jao <jao@gnu.org> | 2026-09-28 21:52:55 +0100 |
| commit | 5ee2ae03e7d835995fa20c12a316bf52795cedf5 (patch) | |
| tree | 139e2ace59c54206f30069db38da38d282e6c8d9 /lib | |
| parent | a6c9577440582dd22ee02501aeae09673eb2b97c (diff) | |
| download | elibs-5ee2ae03e7d835995fa20c12a316bf52795cedf5.tar.gz elibs-5ee2ae03e7d835995fa20c12a316bf52795cedf5.tar.bz2 | |
wee improvementsmain
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/doc/jao-org-focus.el | 12 | ||||
| -rw-r--r-- | lib/doc/jao-words.el | 53 | ||||
| -rw-r--r-- | lib/eos/jao-buffers.el | 8 |
3 files changed, 47 insertions, 26 deletions
diff --git a/lib/doc/jao-org-focus.el b/lib/doc/jao-org-focus.el index a8d72be..859cb65 100644 --- a/lib/doc/jao-org-focus.el +++ b/lib/doc/jao-org-focus.el @@ -124,6 +124,11 @@ With arg, offer to switch to all children, regardless of their parent." (completing-read "Focused child: " fl nil t nil 'jao-org-focus--focused-history)))) +(defun jao-org-focus-goto-line (n) + (interactive "NGo to line: ") + (goto-char (point-min)) + (forward-visible-line n)) + (define-minor-mode org-focus-mode "A mode where keeping track of focused children is on by default." :lighter " ◎" @@ -139,12 +144,17 @@ With arg, offer to switch to all children, regardless of their parent." (define-minor-mode org-focus-child-mode "A mode for the children of a focused org buffer." :lighter " ◉" - :keymap org-focus-mode-map (when (and org-focus-child-mode (require 'symbol-overlay nil t)) (face-remap-reset-base 'symbol-overlay-default-face) (face-remap-add-relative 'symbol-overlay-default-face 'warning 'underline) (symbol-overlay-mode 1))) +(set-keymap-parent org-focus-child-mode-map org-focus-mode) +(keymap-set org-focus-child-mode-map + "<remap> <goto-line>" + #'jao-org-focus-goto-line) + + (with-eval-after-load 'symbol-overlay (keymap-set org-focus-mode-map "M-n" 'symbol-overlay-jump-next) (keymap-set org-focus-mode-map "M-p" 'symbol-overlay-jump-prev)) diff --git a/lib/doc/jao-words.el b/lib/doc/jao-words.el index 52e5093..5d5111d 100644 --- a/lib/doc/jao-words.el +++ b/lib/doc/jao-words.el @@ -24,13 +24,12 @@ ;;; Code: -(defun jao-words--count-words (raw-word-list) - (cl-loop with result = nil - for elt in raw-word-list - do (cl-incf (cdr (or (assoc elt result) - (car (push (cons elt 0) result))))) - finally return (sort result - (lambda (a b) (string< (car a) (car b)))))) +(require 'org) +(require 'cl-lib) + +(defvar jao-words-min-length 3) +(defvar jao-words-max-lines 12) +(defvar jao-words-min-line-distance 10) (defun jao-words--word-lines (buffer word) (let ((lines nil) @@ -40,36 +39,40 @@ (with-current-buffer buffer (save-excursion (goto-char (point-min)) - (while (and (re-search-forward rx nil t) (< (length lines) 12)) + (while (and (< (length lines) jao-words-max-lines) + (re-search-forward rx nil t)) (let* ((line (line-number-at-pos)) (d (- line (or last-line line)))) - (when (<= d 10) + (when (< d jao-words-min-line-distance) (when last-line - (push last-line lines) - (push line lines))) - (setq last-line (line-number-at-pos)))))) + (cl-pushnew last-line lines) + (cl-pushnew line lines))) + (setq last-line line))))) (mapconcat #'number-to-string (nreverse lines) " "))) +;;;###autoload (defun jao-words-show-stats () (interactive) - (let* ((words (split-string (downcase (buffer-string)) "\\W+" t)) - (word-list (jao-words--count-words words)) - (buffer (current-buffer))) + (let ((counts (make-hash-table :test 'equal)) + (buffer (current-buffer))) + (seq-each (lambda (word) + (when (>= (length word) jao-words-min-length) + (puthash word (1+ (gethash word counts 0)) counts))) + (split-string (downcase (buffer-string)) "\\W+" t)) (with-current-buffer (get-buffer-create "*word-statistics*") (erase-buffer) (insert "| word | occurences | lines | |-----------+------------|--------------------|\n") - (dolist (elt word-list) - (let* ((word (car elt)) - (count (cdr elt)) - (lines (jao-words--word-lines buffer word))) - (insert (format "| %s | %d | %s |\n" word count lines)))) + (maphash (lambda (word count) + (let ((lines (jao-words--word-lines buffer word))) + (insert (format "| %s | %d | %s |\n" word count lines)))) + counts) (org-mode) - (indent-region (point-min) (point-max)) - (goto-char 5) - (forward-line 2) - (org-table-next-field) - (org-table-sort-lines nil ?N))) + (org-table-goto-line 2) + (org-table-goto-column 2) + (org-table-sort-lines nil ?N) + (org-table-align) + (org-table-goto-line 2))) (pop-to-buffer "*word-statistics*")) diff --git a/lib/eos/jao-buffers.el b/lib/eos/jao-buffers.el index 7bc3431..2390cf2 100644 --- a/lib/eos/jao-buffers.el +++ b/lib/eos/jao-buffers.el @@ -20,6 +20,14 @@ ;;; Code: +;;;; lines + +;;;###autoload +(defun jao-goto-visible-line (n) + (interactive "NGo to line: ") + (goto-char (point-min)) + (forward-visible-line n)) + ;;;; attached buffers (defun jao-display-buffer-below-selected (buffer alist) (delete-other-windows-vertically) |
