Tuber oregonense, Vysotsky (skyscraper) & Nomina Villarum
This commit is contained in:
parent
e5d4b0a6b1
commit
29409bf9ff
1 changed files with 57 additions and 56 deletions
|
@ -5,7 +5,6 @@
|
||||||
;; Author: nik gaffney <nik@fo.am>
|
;; Author: nik gaffney <nik@fo.am>
|
||||||
;; Created: 2020-12-12
|
;; Created: 2020-12-12
|
||||||
;; Version: 0.1
|
;; Version: 0.1
|
||||||
;; Package-Requires: ((emacs "27.1") (request "0.3") (websocket "1.12") (parsec "0.1") (0xc "0.1"))
|
|
||||||
;; Keywords: comm, etherpad, collaborative editing
|
;; Keywords: comm, etherpad, collaborative editing
|
||||||
;; URL: https://github.com/zzkt/ethermacs
|
;; URL: https://github.com/zzkt/ethermacs
|
||||||
|
|
||||||
|
@ -47,12 +46,12 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
;; (require 'websocket)
|
(require 'websocket)
|
||||||
;; (require 'let-alist)
|
(require 'let-alist)
|
||||||
;; (require 'calc-bin)
|
(require 'calc-bin)
|
||||||
;; (require 'parsec)
|
(require 'parsec)
|
||||||
;; (require '0xc)
|
(require '0xc)
|
||||||
;; (require 's)
|
(require 's)
|
||||||
|
|
||||||
;; debug details
|
;; debug details
|
||||||
;; (setq websocket-debug t)
|
;; (setq websocket-debug t)
|
||||||
|
@ -202,38 +201,38 @@
|
||||||
(cl-labels ((n-36 (n)
|
(cl-labels ((n-36 (n)
|
||||||
(let ((calc-number-radix 36))
|
(let ((calc-number-radix 36))
|
||||||
(downcase (math-format-radix n)))))
|
(downcase (math-format-radix n)))))
|
||||||
(message "encoding: o:%s (%s) cs:%s op:%s ch:%s"
|
(message "encoding: o:%s (%s) cs:%s op:%s ch:%s"
|
||||||
length (n-36 length)
|
length (n-36 length)
|
||||||
change-size ops chars)
|
change-size ops chars)
|
||||||
|
|
||||||
(let* ((change (cond ((= 0 change-size) "=0")
|
(let* ((change (cond ((= 0 change-size) "=0")
|
||||||
((> 0 change-size)
|
((> 0 change-size)
|
||||||
(format "<%s" (n-36 (abs change-size))))
|
(format "<%s" (n-36 (abs change-size))))
|
||||||
((< 0 change-size)
|
((< 0 change-size)
|
||||||
(format ">%s" (n-36 change-size)))))
|
(format ">%s" (n-36 change-size)))))
|
||||||
(newline-count (s-count-matches "\n" (buffer-substring
|
(newline-count (s-count-matches "\n" (buffer-substring
|
||||||
(point-min)
|
(point-min)
|
||||||
(point))))
|
(point))))
|
||||||
(offset (- (point) (length chars) 1))
|
(offset (- (point) (length chars) 1))
|
||||||
;; offset is distance from point-min to point w.out inserted chars and w. newlines
|
;; offset is distance from point-min to point w.out inserted chars and w. newlines
|
||||||
(pos-op (if (< 0 newline-count)
|
(pos-op (if (< 0 newline-count)
|
||||||
(format "|%s=%s"
|
(format "|%s=%s"
|
||||||
;; 2 steps reqd. newline insert, then from beginning of line?
|
;; 2 steps reqd. newline insert, then from beginning of line?
|
||||||
(n-36 newline-count)
|
(n-36 newline-count)
|
||||||
(let ((p1 (- offset
|
(let ((p1 (- offset
|
||||||
(caar
|
(caar
|
||||||
(reverse
|
(reverse
|
||||||
(s-matched-positions-all
|
(s-matched-positions-all
|
||||||
"\n" (buffer-substring
|
"\n" (buffer-substring
|
||||||
(point-min) (point))))))))
|
(point-min) (point))))))))
|
||||||
(message "offset: %s p1: %s" offset p1)
|
(message "offset: %s p1: %s" offset p1)
|
||||||
(if (= 1 p1)
|
(if (= 1 p1)
|
||||||
(n-36 (+ 1 offset))
|
(n-36 (+ 1 offset))
|
||||||
(format "%s=%s"
|
(format "%s=%s"
|
||||||
(n-36 (- offset p1 -1))
|
(n-36 (- offset p1 -1))
|
||||||
(n-36 (- p1 1))))))
|
(n-36 (- p1 1))))))
|
||||||
(format "=%s" (n-36 offset)))))
|
(format "=%s" (n-36 offset)))))
|
||||||
(format "Z:%s%s%s%s$%s" (n-36 length) change pos-op ops chars))))
|
(format "Z:%s%s%s%s$%s" (n-36 length) change pos-op ops chars))))
|
||||||
|
|
||||||
|
|
||||||
(defun etherpad-esync--send-user-changes (cs)
|
(defun etherpad-esync--send-user-changes (cs)
|
||||||
|
@ -277,24 +276,25 @@
|
||||||
pair should just be omitted."
|
pair should just be omitted."
|
||||||
|
|
||||||
(let* ((changes
|
(let* ((changes
|
||||||
(parsec-with-input cs
|
(parsec-with-input
|
||||||
;; a letter Z (the "magic character" and format version identifier)
|
cs
|
||||||
(parsec-str "Z")
|
;; a letter Z (the "magic character" and format version identifier)
|
||||||
(parsec-collect*
|
(parsec-str "Z")
|
||||||
;; source text length
|
(parsec-collect*
|
||||||
(parsec-re ":[0-9a-z]+")
|
;; source text length
|
||||||
;; change in text length
|
(parsec-re ":[0-9a-z]+")
|
||||||
(parsec-re "[>=<][0-9a-z]+")
|
;; change in text length
|
||||||
;; insertion & deletion operations
|
(parsec-re "[>=<][0-9a-z]+")
|
||||||
(parsec-many
|
;; insertion & deletion operations
|
||||||
(parsec-or
|
(parsec-many
|
||||||
(parsec-re "|[0-9a-z]+[+-=][0-9a-z]+")
|
(parsec-or
|
||||||
(parsec-re "[><+-=*][0-9a-z]+")))
|
(parsec-re "|[0-9a-z]+[+-=][0-9a-z]+")
|
||||||
;; separator
|
(parsec-re "[><+-=*][0-9a-z]+")))
|
||||||
(parsec-str "$")
|
;; separator
|
||||||
;; a string of characters used by insertion operations (the "char bank")
|
(parsec-str "$")
|
||||||
(parsec-many-s
|
;; a string of characters used by insertion operations (the "char bank")
|
||||||
(parsec-any-ch))))))
|
(parsec-many-s
|
||||||
|
(parsec-any-ch))))))
|
||||||
|
|
||||||
(let* ((old-length
|
(let* ((old-length
|
||||||
(0xc-string-to-number (substring (car changes) 1) 36))
|
(0xc-string-to-number (substring (car changes) 1) 36))
|
||||||
|
@ -381,6 +381,7 @@ Numeric offsets are calculated from the beginning of the buffer."
|
||||||
(insert chars))))
|
(insert chars))))
|
||||||
|
|
||||||
(defun etherpad-esync-try-changeset (cs)
|
(defun etherpad-esync-try-changeset (cs)
|
||||||
|
"Try changeset CS."
|
||||||
(let* ((changes
|
(let* ((changes
|
||||||
(etherpad-esync-parse-changeset cs))
|
(etherpad-esync-parse-changeset cs))
|
||||||
(len (nth 0 changes))
|
(len (nth 0 changes))
|
||||||
|
|
Loading…
Reference in a new issue