A listing drawn after a commit is a listing again
`flan-inspect-edit' turns off read-only and line truncation, and `--show' is the one funnel every drawing goes through — but the mode body that set them in the first place does not run a second time on a buffer already in the mode. So a listing drawn after a commit or an abandon presented as a listing and was plain editable text: `C-k' on one of its lines did what `C-k' does. Put back beside the flag that says which of the two the buffer is. And that flag is now the marker it should have been. The header above the value is two lines or three depending on whether the daemon named a type, and the count that skipped it was written once in the writer and once in the reader that parses the buffer back — two places to keep in step for nothing. The MANUAL's key table lists the two keys that commit and abandon, which were in the prose and not in the table anybody scans.
This commit is contained in:
parent
416ce10ee7
commit
d43c372efe
@ -378,6 +378,8 @@ per line.
|
||||
| `S-TAB` / `p` | previous field |
|
||||
| `e` | set the field at point |
|
||||
| `C-c C-e` | open the value for editing |
|
||||
| `C-c C-c` | commit what you changed in it |
|
||||
| `C-c C-k` | abandon the edit |
|
||||
| `q` | close |
|
||||
|
||||
Two things worth knowing, because they are unlike other inspectors.
|
||||
|
||||
@ -435,7 +435,10 @@ its loop and stopped again since: what is on the screen would then describe
|
||||
storage that has moved, and overwriting it would be aimed at nothing anybody
|
||||
looked at.")
|
||||
(defvar-local flan-inspect--editing nil
|
||||
"Non-nil while this buffer is the value rather than a listing of it.")
|
||||
"Where the value starts, while this buffer is the value rather than a listing.
|
||||
A marker and not a flag, because the header above it is two lines or three
|
||||
depending on whether the daemon named a type, and the reader that parses the
|
||||
buffer back has to start in the same place this one stopped writing.")
|
||||
|
||||
(defun flan-inspect--label (child)
|
||||
"How CHILD is named in the list: `0.' for an element, `.x' for a field.
|
||||
@ -662,6 +665,13 @@ and whether that may be followed is the answer"))
|
||||
(setq flan-inspect--at-stop (plist-get answer :at-stop))
|
||||
(setq flan-inspect--stack stack)
|
||||
(setq flan-inspect--editing nil)
|
||||
;; Put back what editing turned off, here and not in the two commands
|
||||
;; that leave it: this is the one funnel every drawing goes through, and
|
||||
;; the mode body that set them in the first place does not run a second
|
||||
;; time on a buffer that is already in the mode. Without it a listing
|
||||
;; drawn after a commit is a listing you can yank into.
|
||||
(setq buffer-read-only t)
|
||||
(setq-local truncate-lines t)
|
||||
(flan-inspect--render root path flan-inspect--node stack
|
||||
flan-inspect--type))
|
||||
(display-buffer buf)
|
||||
@ -1096,25 +1106,29 @@ program holds afterwards, `C-c C-k' throws the edit away."
|
||||
"--- Editing. C-c C-c commits what you changed, C-c C-k abandons it.\n"
|
||||
'face 'font-lock-comment-face))
|
||||
(insert "\n")
|
||||
;; Where the value starts, recorded rather than counted back to. The
|
||||
;; header above is two lines or three depending on whether the daemon
|
||||
;; named a type, and a count written here and again in the reader is two
|
||||
;; places to keep in step for no gain.
|
||||
(setq flan-inspect--editing (point-marker))
|
||||
(set-marker-insertion-type flan-inspect--editing nil)
|
||||
(insert (flan-inspect--literal flan-inspect--node))
|
||||
(insert "\n")
|
||||
(setq buffer-read-only nil)
|
||||
(setq-local truncate-lines nil)
|
||||
(setq flan-inspect--editing t)
|
||||
;; The header is not part of the value, so it is not part of what gets
|
||||
;; parsed back — and it is fixed rather than merely un-parsed, because a
|
||||
;; header edited by accident would otherwise read as the value having
|
||||
;; grown a line.
|
||||
(let ((end (save-excursion (goto-char (point-min)) (forward-line 4) (point))))
|
||||
(add-text-properties (point-min) end '(read-only t front-sticky t)))
|
||||
(add-text-properties (point-min) (marker-position flan-inspect--editing)
|
||||
'(read-only t front-sticky t))
|
||||
(goto-char (point-max))
|
||||
(forward-line -1)))
|
||||
|
||||
(defun flan-inspect--edited ()
|
||||
"What the editable part of this buffer says, parsed."
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(forward-line 4)
|
||||
(goto-char (marker-position flan-inspect--editing))
|
||||
(let ((text (buffer-substring-no-properties (point) (point-max))))
|
||||
(when (string-empty-p (string-trim text))
|
||||
(user-error "flan: there is nothing left in the buffer to commit"))
|
||||
|
||||
@ -918,7 +918,12 @@ would be overwritten. Look again and re-do the edit")
|
||||
(flan-inspect-abandon)
|
||||
(test-flan--check "and abandoning draws what the program holds"
|
||||
(and (not flan-inspect--editing)
|
||||
(string-match-p "\\.id +7" (buffer-string))))))
|
||||
(string-match-p "\\.id +7" (buffer-string))))
|
||||
;; The listing is read-only again, and that is the assertion rather than
|
||||
;; the flag: the flag says which mode the buffer is in, this says whether
|
||||
;; `C-k' on a line of the listing would do something.
|
||||
(test-flan--check "and the listing is read-only again afterwards"
|
||||
buffer-read-only)))
|
||||
|
||||
(test-flan--writable
|
||||
"(Blob {.id 7})" "Blob" nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user