Skip to content

Commit

Permalink
Fix issue where tags fields values first character was read-only
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyatt committed Jul 21, 2024
1 parent f92d6c9 commit 2b4a8bb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions Eldev
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

(eldev-use-package-archive 'gnu-elpa)
(eldev-use-plugin 'maintainer)
(eldev-add-extra-dependencies 'test '(:package markdown-mode :archive melpa))
28 changes: 28 additions & 0 deletions ekg-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
(require 'ert)
(require 'ert-x)
(require 'org)
(require 'markdown-mode)
(require 'ekg-test-utils)

(ekg-deftest ekg-test-note-lifecycle ()
Expand Down Expand Up @@ -316,6 +317,33 @@
(should (= (overlay-end o) (+ 1 (length "Tags: test\n"))))
(should (= (point) (overlay-end o))))))

(ekg-deftest ekg-test-metadata-read-only ()
(dolist (mode '(org-mode markdown-mode text-mode))
(let ((ekg-capture-default-mode mode))
(cl-loop for i from 1 to 10
do
(ekg-capture)
;; TODO(ahyatt) Find out why this is necessary to reproduce bad
;; behavior.
(funcall mode)
(goto-char i)
(cond
((= i 1)
(ert-info
((format "%s: Inserting text at position %d in beginning of the line should be allowed."
mode i))
(insert "foo")))
((> i (length "Tags: "))
(ert-info
((format "%s: Inserting text at position %d in the field value should be allowed."
mode i))
(insert "foo")))
(t (ert-info
((format "%s: Inserting text at position %d in the tag field name should not be allowed."
mode i))
(should-error (insert "foo")))))
(kill-buffer)))))

(ekg-deftest ekg-test-draft ()
(ekg-capture :tags '("test"))
(insert "foo")
Expand Down
2 changes: 1 addition & 1 deletion ekg.el
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ This will be displayed at the top of the note buffer."
(format "%s%s%s"
(concat
(propertize (concat property ":") 'face 'bold 'read-only read-only)
(propertize " " 'read-only read-only 'rear-nonsticky t))
(propertize " " 'read-only nil 'rear-nonsticky t))
value
(propertize "\n" 'read-only read-only 'rear-nonsticky t))))

Expand Down

0 comments on commit 2b4a8bb

Please sign in to comment.