Skip to content

Commit

Permalink
Merge pull request #380 from ardumont/0.8.1
Browse files Browse the repository at this point in the history
0.8.1
  • Loading branch information
ardumont committed Mar 11, 2018
2 parents d788503 + e4e7c84 commit c38c361
Show file tree
Hide file tree
Showing 18 changed files with 1,395 additions and 1,139 deletions.
8 changes: 4 additions & 4 deletions TESTS-simple.org
Expand Up @@ -9,9 +9,9 @@
#+PROPERTY: IN-PROGRESS 53fc6e17b928efc254b028fa
#+PROPERTY: TODO 53fc6e1754c24b2ab5d5eef5
#+TODO: TODO IN-PROGRESS | DONE PENDING DELEGATED FAILED CANCELLED
#+PROPERTY: orgtrello-user-antoineromaindumont 554b1f596ca33dd8f79e974b
#+PROPERTY: orgtrello-user-orgmode 5203a0c833fc36360800177f
#+PROPERTY: orgtrello-user-ardumont 4f2baa2f72b7c1293501cad3
#+PROPERTY: orgtrello_user_antoineromaindumont 554b1f596ca33dd8f79e974b
#+PROPERTY: orgtrello_user_orgmode 5203a0c833fc36360800177f
#+PROPERTY: orgtrello_user_ardumont 4f2baa2f72b7c1293501cad3
#+PROPERTY: :yellow yello
#+PROPERTY: :lime green lime
#+PROPERTY: :pink pink?
Expand All @@ -24,7 +24,7 @@
#+PROPERTY: :black arf
#+PROPERTY: :green green label with & char
#+PROPERTY: :orange range
#+PROPERTY: orgtrello-user-me ardumont
#+PROPERTY: orgtrello_user_me ardumont
:END:
#+title: dummy sample to sync with trello
#+author: Antoine R. Dumont
Expand Down
11 changes: 10 additions & 1 deletion TODO.org
Expand Up @@ -2,7 +2,7 @@
#+AUTHOR: ardumont
#+STYLE: <style> h1,h2,h3 {font-family: arial, helvetica, sans-serif} </style>

* TODO Backlog** Bug
* TODO Backlog Bug
- [ ] #240 - Preserve non-trello related tags/other meta data
- [ ] #278 - Too much checklist sync?

Expand Down Expand Up @@ -31,6 +31,15 @@
- [ ] #245 - Trying to sync a card: orgtrello-buffer/compute-marker: Wrong type argument: numberp, nil
- [ ] #248 - Installing from melpa (unstable) works, but then it errs on an undefined variable "error-messages"
- [ ] #263 - Colors broken in org trello
* IN-PROGRESS 0.8.1 [100%]
- [X] Make adding trello colors to `org-tag-alist` optional - Close #365
- [X] Fix typo in link to issue tracker - Close #364
- [X] Fix ci
- [X] Fix user properties search in agenda view - Close #366 - Close #371
- [X] Correct bad encoding of json encoded data.
- [X] Update version
- [X] Release notes

* DONE 0.8.0 [100%]
CLOSED: [2017-02-25 Sat 21:31]

Expand Down
44 changes: 38 additions & 6 deletions org-trello-buffer.el
Expand Up @@ -214,8 +214,8 @@ This to avoid conflict between `org-mode' and markdown syntax."
(comment-str (-> comment
orgtrello-data-entity-comment-text
orgtrello-buffer--prepare-comment)))
(format "\n** COMMENT %s, %s\n:PROPERTIES:\n:orgtrello-id: %s\n:END:\n%s\n"
comment-user comment-date comment-id comment-str)))
(format "\n** COMMENT %s, %s\n:PROPERTIES:\n:%s: %s\n:END:\n%s\n"
comment-user comment-date org-trello--label-key-id comment-id comment-str)))

(defun orgtrello-buffer-update-properties-unknown (unknown-properties)
"Write the alist UNKNOWN-PROPERTIES inside standard properties org drawer."
Expand Down Expand Up @@ -669,8 +669,10 @@ Also add some metadata identifier/due-data/point/buffer-name/etc..."

(defun orgtrello-buffer--filter-out-known-properties (l)
"Filter out the known org-trello properties from L."
(--filter (not (or (string-match-p "^orgtrello-.*" (car it))
(string= "CATEGORY" (car it)))) l))
(--filter (let ((v (car it)))
(not (or (string-match-p "^orgtrello-.*" v)
(string-match-p "^orgtrello_.*" v)
(string= "CATEGORY" v)))) l))

(defun orgtrello-buffer-org-unknown-drawer-properties ()
"Retrieve the key/value pairs of org-trello unknown drawer properties."
Expand Down Expand Up @@ -830,10 +832,10 @@ Return nil if none."
"Compute the orgtrello marker which is composed of BUFFER-NAME, NAME and POSITION."
(->> (list org-trello--label-key-marker buffer-name name
(if (stringp position) position (int-to-string position)))
(-interpose "-")
(-interpose org-trello--property-separator)
(apply 'concat)
sha1
(concat org-trello--label-key-marker "-")))
(concat org-trello--label-key-marker org-trello--property-separator)))

(defun orgtrello-buffer-save-buffer (buffer-name)
"Given a BUFFER-NAME, save it."
Expand Down Expand Up @@ -916,6 +918,36 @@ COMPUTE-REGION-FN is the region computation function (takes no parameter)."
trello-cards) ;; find a card to archive
(org-archive-subtree)))))))

(defun orgtrello-buffer-to-migrate-p ()
"Check if the current buffer needs migration or not."
(save-excursion
(with-current-buffer (current-buffer)
(when (let ((case-fold-search t))
(search-forward-regexp
"orgtrello-id\\|orgtrello-local-checksum\\|orgtrello-marker-\\|orgtrello-user-\\|:orgtrello-users:"
nil t))
t))))

(defun orgtrello-buffer-migrate-buffer ()
"Migrate the old properties to the new one.
The cursor remains at current position once the computation is done."
(defun orgtrello-buffer--replace-str (str new)
"Replace all strings matching STR with NEW.
The cursor moves along the search."
(goto-char (point-min))
(while (search-forward str nil t)
(replace-match new)))

(save-excursion
(with-current-buffer (current-buffer)
(let ((case-fold-search t)
(old-new `(("orgtrello-id" ,org-trello--label-key-id)
("orgtrello-local-checksum" ,org-trello--label-key-local-checksum)
("orgtrello-marker-" ,(format "%s%s" org-trello--label-key-marker org-trello--property-separator))
("orgtrello-user-" ,org-trello--label-key-user-prefix)
(":orgtrello-users:" ,(format ":%s:" org-trello--property-users-entry)))))
(--map (orgtrello-buffer--replace-str (car it) (cadr it)) old-new)))))

(orgtrello-log-msg orgtrello-log-debug "orgtrello-buffer loaded!")

(provide 'org-trello-buffer)
Expand Down
23 changes: 16 additions & 7 deletions org-trello-controller.el
Expand Up @@ -88,13 +88,14 @@ ARGS is not used."
org-trello--user-logged-in (or (orgtrello-buffer-me)
(orgtrello-setup-user-logged-in)))

(mapc (-partial #'add-to-list 'org-tag-alist)
'(("red" . ?r)
("green" . ?g)
("yellow" . ?y)
("blue" . ?b)
("purple" . ?p)
("orange" . ?o)))
(when org-trello-add-tags
(mapc (-partial #'add-to-list 'org-tag-alist)
'(("red" . ?r)
("green" . ?g)
("yellow" . ?y)
("blue" . ?b)
("purple" . ?p)
("orange" . ?o))))
:ok))

(defun orgtrello-controller-control-properties (&optional args)
Expand Down Expand Up @@ -133,6 +134,14 @@ ARGS is not used."
(delete-directory org-trello--old-config-dir 'with-contents)))
:ok)

(defun orgtrello-controller-migrate-user-buffer (&optional args)
"Migrate user's setup file according to latest development.
ARGS is not used."
(when (orgtrello-buffer-to-migrate-p)
(orgtrello-log-msg orgtrello-log-warn "Migrate the buffer's keys to the correct new one (https://org-trello.github.io/migration.html#081).")
(orgtrello-buffer-migrate-buffer))
:ok)

(defun orgtrello-controller-config-file (&optional username)
"Determine the configuration file as per user logged in.
If USERNAME is supplied, do not look into the current buffer."
Expand Down
2 changes: 1 addition & 1 deletion org-trello-data.el
Expand Up @@ -236,7 +236,7 @@ SIZE is a useless parameter, only here to satisfy an implementation detail."

(defun orgtrello-data-id-p (id)
"Is the string ID a trello identifier?"
(and id (not (string-match-p (format "^%s-" org-trello--label-key-marker) id))))
(and id (not (string-match-p (format "^%s%s" org-trello--label-key-marker org-trello--property-separator) id))))

(defun orgtrello-data--merge-item (trello-item org-item)
"Merge TRELLO-ITEM and ORG-ITEM together.
Expand Down
2 changes: 1 addition & 1 deletion org-trello-pkg.el
@@ -1,4 +1,4 @@
(define-package "org-trello" "0.8.0" "Minor mode to synchronize org-mode buffer and trello board"
(define-package "org-trello" "0.8.1" "Minor mode to synchronize org-mode buffer and trello board"
'((request-deferred "0.2.0")
(deferred "0.4.0")
(s "1.11.0")
Expand Down
2 changes: 1 addition & 1 deletion org-trello-query.el
Expand Up @@ -94,7 +94,7 @@ Simply displays a success message in the minibuffer."
(params (when authentication-p (orgtrello-query--authentication-params)))
(parser 'orgtrello-query--http-parse)
(headers '(("Content-type" . "application/json")))
(data (->> query-map orgtrello-data-entity-params json-encode))
(data (encode-coding-string (->> query-map orgtrello-data-entity-params json-encode) 'utf-8))
(success-cbck (if success-callback success-callback 'orgtrello-query--standard-success-callback))
(error-cbck (if error-callback error-callback 'orgtrello-query--standard-error-callback)))
(if (orgtrello-data-entity-sync query-map)
Expand Down
29 changes: 18 additions & 11 deletions org-trello-setup.el
Expand Up @@ -42,9 +42,6 @@

(defvar *access-token*) ;; for retro compatibility

(defconst org-trello--label-key-marker "orgtrello-marker"
"A marker used inside the org buffer to synchronize entries.")

(defconst org-trello--card-level 1
"Card level.")

Expand All @@ -60,20 +57,33 @@
(defconst org-trello--out-of-bounds-level 4
"Out of bounds level.")

(defconst org-trello--label-key-user-prefix "orgtrello-user-"
(defconst org-trello--property-separator "_"
"Separator used for org-trello's property key.")

(defconst org-trello--property-prefix-key "orgtrello_"
"Org-trello property prefix key.")

(defconst org-trello--label-key-marker (format "%smarker" org-trello--property-prefix-key)
"A marker used inside the org buffer to synchronize entries.")

(defconst org-trello--label-key-user-prefix (format "%suser_" org-trello--property-prefix-key)
"Org-trello prefix to define user to a 'org-mode' level.")

(defconst org-trello--property-users-entry "orgtrello-users"
(defconst org-trello--property-users-entry (format "%susers" org-trello--property-prefix-key)
"Org-trello property entry to store the users assigned to a card.")

(defconst org-trello--property-user-me "orgtrello-user-me"
(defconst org-trello--property-user-me (format "%suser_me" org-trello--property-prefix-key)
"Current user's property id.")

(defconst org-trello--label-key-id (format "%sid" org-trello--property-prefix-key)
"Key entry used for the trello identifier and the trello marker (the first sync).")

(defconst org-trello--label-key-local-checksum (format "%slocal_checksum" org-trello--property-prefix-key)
"Current card's checksum property.")

(defvar org-trello--user-logged-in nil
"Current user logged in.")

(defconst org-trello--label-key-local-checksum "orgtrello-local-checksum"
"Current card's checksum property.")

(defconst org-trello--title-buffer-information "*org-trello-information*"
"Title for the org-trello buffers that display information.")
Expand Down Expand Up @@ -190,9 +200,6 @@ As of 0.7.0, org-trello now follows Emacs's conventions.")
(defconst org-trello--config-file (expand-file-name (format "%s/%s" org-trello--config-dir org-trello--config-filename))
"Absolute path to org-trello's config file.")

(defconst org-trello--label-key-id "orgtrello-id"
"Key entry used for the trello identifier and the trello marker (the first sync).")

(defconst org-trello-buffer--indent-description 2
"The default card description's indentation column.")

Expand Down
18 changes: 16 additions & 2 deletions org-trello.el
Expand Up @@ -4,7 +4,7 @@

;; Author: Antoine R. Dumont (@ardumont) <antoine.romain.dumont@gmail.com>
;; Maintainer: Antoine R. Dumont (@ardumont) <antoine.romain.dumont@gmail.com>
;; Version: 0.8.0
;; Version: 0.8.1
;; Package-Requires: ((dash "2.12.1") (dash-functional "2.12.1") (s "1.11.0") (deferred "0.4.0") (request-deferred "0.2.0"))
;; Keywords: org-mode trello sync org-trello
;; URL: https://github.com/org-trello/org-trello
Expand Down Expand Up @@ -95,7 +95,7 @@
;; Enjoy!
;;
;; More informations: https://org-trello.github.io
;; Issue tracker: https://github.com/org-trello/org-trello-issues
;; Issue tracker: https://github.com/org-trello/org-trello/issues

;;; Code:

Expand Down Expand Up @@ -187,6 +187,7 @@ If WITH-SAVE-FLAG is set, will do a buffer save and reload the org setup."
(orgtrello-action-msg-controls-or-actions-then-do
action-label
'(orgtrello-controller-migrate-user-setup
orgtrello-controller-migrate-user-buffer
orgtrello-controller-set-account
orgtrello-controller-load-keys
orgtrello-controller-control-keys
Expand All @@ -202,6 +203,7 @@ If NO-CHECK-FLAG is set, no controls are done."
(orgtrello-action-msg-controls-or-actions-then-do
action-label
(if no-check-flag nil '(orgtrello-controller-migrate-user-setup
orgtrello-controller-migrate-user-buffer
orgtrello-controller-set-account
orgtrello-controller-load-keys
orgtrello-controller-control-keys
Expand Down Expand Up @@ -468,6 +470,12 @@ If UNASSIGN is not nil, unassign oneself from the card."
nil
'no-log))

;;;### autoload
(defun org-trello-migrate-buffer ()
"Migrate the buffer's property keys to the actual new ones."
(interactive)
(orgtrello-buffer-migrate-buffer))

;;;###autoload
(defun org-trello-clean-org-trello-data ()
"Clean up org-trello data."
Expand Down Expand Up @@ -588,6 +596,12 @@ This does not support regular expression."
org-trello-files)
(org-trello-mode))))

(defcustom org-trello-add-tags t
"Add trello colors to org tags list?"
:type 'boolean
:require 'org-trello
:group 'org-trello)

(orgtrello-log-msg orgtrello-log-debug "org-trello loaded!")

(provide 'org-trello)
Expand Down
10 changes: 10 additions & 0 deletions release-notes.md
@@ -1,3 +1,13 @@
# 0.8.1

- [X] Make adding trello colors to `org-tag-alist` optional - Close #365
- [X] Fix typo in link to issue tracker - Close #364
- [X] Fix ci
- [X] Fix user properties search in agenda view - Close #366 - Close #371
- [X] Correct bad encoding of json encoded data.
- [X] Update version
- [X] Release notes

# 0.8.0

- [X] Update travis ci configuration
Expand Down
2 changes: 1 addition & 1 deletion run-tests.sh
Expand Up @@ -3,7 +3,7 @@
for version in $*; do
EMACS_NAME=emacs-$version
# forge the right path
PATH=$(evm bin $EMACS_NAME):~/.evm/bin/:~/.cask/bin/:/usr/bin/:/bin
PATH=$(evm bin $EMACS_NAME):~/.evm/bin/:~/.cask/bin/:/usr/local/bin:/usr/bin/:/bin
# use the emacs version
evm use $EMACS_NAME
# check the right emacs version is found
Expand Down

0 comments on commit c38c361

Please sign in to comment.