emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/doc-toc b1a843fd6f 57/84: Implement roman-to-arabic and


From: ELPA Syncer
Subject: [elpa] externals/doc-toc b1a843fd6f 57/84: Implement roman-to-arabic and add pdf djvu keybindings
Date: Mon, 26 Sep 2022 13:58:38 -0400 (EDT)

branch: externals/doc-toc
commit b1a843fd6f8406c2f24f957182f9d79537fc84f9
Author: Daniel Nicolai <dalanicolai@gmail.com>
Commit: Daniel Nicolai <dalanicolai@gmail.com>

    Implement roman-to-arabic and add pdf djvu keybindings
---
 toc-mode.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/toc-mode.el b/toc-mode.el
index 50d8c7409f..fc75873842 100644
--- a/toc-mode.el
+++ b/toc-mode.el
@@ -164,6 +164,7 @@
 (require 'djvu nil t)
 (require 'evil nil t)
 (require 'seq)
+(require 'rst)
 
 ;; List of declarations to eliminate byte-compile errors
 (defvar djvu-doc-image)
@@ -261,6 +262,18 @@ Like `toc--cleanup-dots' but more suited for use after OCR"
   (goto-char (point-min))
   (flush-lines "^ *$"))
 
+(defun toc--roman-to-arabic (count)
+  (interactive "p")
+  (dotimes (_x count) 
+    (move-end-of-line 1)
+    (let ((latin (number-to-string
+                  (rst-roman-to-arabic
+                   (thing-at-point 'word t)))))
+      (backward-word)
+      (kill-word 1)
+      (insert latin)
+      (forward-line))))
+
 (defun toc--join-next-unnumbered-lines ()
   "Search from point for first occurence of line not ending with Western 
numerals."
   (interactive)
@@ -480,10 +493,16 @@ Prompt for startpage and endpage and print OCR output to 
new buffer."
 
 ;;;; toc major modes
 
+(define-key pdf-view-mode-map (kbd "C-c C-e") 'toc-extract-pages)
+(define-key djvu-read-mode-map (kbd "C-c C-e") 'toc-extract-pages)
+(define-key pdf-view-mode-map (kbd "C-c e") 'toc-extract-pages-ocr)
+(define-key djvu-read-mode-map (kbd "C-c e") 'toc-extract-pages-ocr)
+
 (defvar toc-cleanup-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "\C-c\C-c" #'toc--create-tablist-buffer)
     (define-key map "\C-c\C-j" #'toc--join-next-unnumbered-lines)
+    (define-key map "\C-c\C-s" #'toc--roman-to-arabic)
     map))
 
 (define-derived-mode toc-cleanup-mode



reply via email to

[Prev in Thread] Current Thread [Next in Thread]