Merge branch 'bugfix' into emacs-sync

This commit is contained in:
Kyle Meyer 2022-02-13 12:42:32 -05:00
commit 7ba1271556
3 changed files with 69 additions and 3 deletions

View File

@ -655,7 +655,8 @@ With a prefix arg, query for optional fields."
(defun org-bibtex-read ()
"Read a bibtex entry and save to `org-bibtex-entries'.
This uses `bibtex-parse-entry'."
This uses `bibtex-parse-entry'.
Return the new value of `org-bibtex-entries'."
(interactive)
(let ((keyword (lambda (str) (intern (concat ":" (downcase str)))))
(clean-space (lambda (str) (replace-regexp-in-string
@ -678,7 +679,8 @@ This uses `bibtex-parse-entry'."
(funcall clean-space (funcall strip-delim (cdr pair)))))
(save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry)))
org-bibtex-entries)
(unless (car org-bibtex-entries) (pop org-bibtex-entries))))
(unless (car org-bibtex-entries) (pop org-bibtex-entries))
org-bibtex-entries))
(defun org-bibtex-read-buffer (buffer)
"Read all bibtex entries in BUFFER and save to `org-bibtex-entries'.

View File

@ -1442,7 +1442,7 @@ This function returns, destructively, the new list structure."
(save-excursion
(goto-char (org-list-get-last-item item struct prevs))
(point-at-eol)))
((string-match-p "\\`[0-9]+\\'" dest)
((and (stringp dest) (string-match-p "\\`[0-9]+\\'" dest))
(let* ((all (org-list-get-all-items item struct prevs))
(len (length all))
(index (mod (string-to-number dest) len)))

View File

@ -900,6 +900,70 @@ b. Item 2<point>"
(org-insert-item)
(buffer-string)))))
(ert-deftest test-org-list/send-item ()
"Test `org-list-send-item' specifications."
;; Move to beginning
(should
(equal "- item3\n- item1\n- item2\n"
(org-test-with-temp-text
"- item1\n- item2\n- item3\n"
(org-list-send-item (caar (last (org-list-struct)))
'begin (org-list-struct))
(buffer-string))))
;; Move to beginning with child item
(should
(equal "- item3\n - item4\n- item1\n- item2\n"
(org-test-with-temp-text
"- item1\n- item2\n- item3\n - item4\n"
(org-list-send-item (car (nth 2 (org-list-struct)))
'begin (org-list-struct))
(buffer-string))))
;; Move to end
(should
(equal "- item2\n- item3\n - item4\n- item1\n - item1child\n"
(org-test-with-temp-text
"- item1\n - item1child\n- item2\n- item3\n - item4\n"
(org-list-send-item (car (nth 0 (org-list-struct)))
'end (org-list-struct))
(buffer-string))))
;; Move to item number by string should move the item before the specified one
(should
(equal "- item2\n- item1\n - item1child\n- item3\n- item4\n- item5\n"
(org-test-with-temp-text
"- item1\n - item1child\n- item2\n- item3\n- item4\n- item5\n"
(org-list-send-item (car (nth 0 (org-list-struct)))
"3" (org-list-struct))
(buffer-string))))
;; Move to item number by position should move the item before the specified one
(should
(equal "- item2\n- item1\n - item1child\n- item3\n- item4\n- item5\n"
(org-test-with-temp-text
"- item1\n - item1child\n- item2\n- item3\n- item4\n- item5\n"
(re-search-forward "item3")
(org-list-send-item (car (nth 0 (org-list-struct)))
(point-at-bol) (org-list-struct))
(buffer-string))))
;; Delete
(should
(equal "- item1\n - item1child\n- item2\n- item4\n- item5\n"
(org-test-with-temp-text
"- item1\n - item1child\n- item2\n- item3\n- item4\n- item5\n"
(re-search-forward "item3")
(org-list-send-item (point-at-bol)
'delete (org-list-struct))
(buffer-string))))
;; Kill
(let ((kill-ring nil))
(org-test-with-temp-text
"- item1\n - item1child\n- item2\n- item3\n - item3child\n- item4\n- item5\n"
(re-search-forward "item3")
(org-list-send-item (point-at-bol)
'kill (org-list-struct))
(should (equal "- item1\n - item1child\n- item2\n- item4\n- item5\n"
(buffer-string)))
(should (equal "item3\n - item3child"
(current-kill 0 t))))))
(ert-deftest test-org-list/repair ()
"Test `org-list-repair' specifications."
;; Repair indentation.