aziz / PlainTasks

An opinionated todo-list plugin for Sublime Text editor (version 2 and 3)
MIT License
3.29k stars 287 forks source link

When the task is completed, the name/contact from author is add. #128

Open rbarros opened 10 years ago

rbarros commented 10 years ago

Came the need to share with someone else the same .todo file. The idea would be to add the name/email from whom modified the task.

E.g:

✔ Task 1. @bug @done (14-03-06 15:48) User1 <user1@domain.com> ✘ Task 2. @change @cancelled (14-03-06 15:48) User2 <user2@domain.com>

E.g PlainTasks.sublime-settings:

{
    "author": {
        "name":"User1",
        "email": "user1@domain.com"
    }
}

Code:

class PlainTasksBase
  def run(self, edit):
        self.taskpaper_compatible = self.view.settings().get('taskpaper_compatible')

        if self.view.settings().get('author'):
            self.author = self.view.settings().get('author')
            if self.author.get('name'):
                self.author_name = '%s' % (self.author.get('name'))
            else:
                self.author_name = ""
            if self.author.get('email'):
                self.author_email = '<%s>' % (self.author.get('email'))
            else:
                self.author_email = ""
            self.author = ' %s%s ' % (self.author_name, self.author_email)
...

class PlainTasksCompleteCommand(PlainTasksBase):
    def runCommand(self, edit):
        original = [r for r in self.view.sel()]
        try:
            done_line_end = ' %s%s%s%s' % (self.done_tag, self.before_date_space, datetime.now().strftime(self.date_format).decode(self.sys_enc), self.author)
        except:
            done_line_end = ' %s%s%s%s' % (self.done_tag, self.before_date_space, datetime.now().strftime(self.date_format), self.author)
...

class PlainTasksCancelCommand(PlainTasksBase):
    def runCommand(self, edit):
        original = [r for r in self.view.sel()]
        try:
            canc_line_end = ' %s%s%s%s' % (self.canc_tag,self.before_date_space, datetime.now().strftime(self.date_format).decode(self.sys_enc), self.author)
        except:
            canc_line_end = ' %s%s%s%s' % (self.canc_tag,self.before_date_space, datetime.now().strftime(self.date_format), self.author)
vovkkk commented 10 years ago

Nice. I would change email to contact (so it could be Skype or corporate chat (irc, jabber, whatever)). related #88

Also,

self.author = self.view.settings().get('author', None)
self.author_name = self.author['name'] if self.author else ''
self.author_email = self.author['email'] if self.author else ''
self.author = ' %s <%s>' % (self.author_name, self.author_email)

or

self.author = self.view.settings().get('author')
if self.author:
    self.author_name = self.author['name']
    self.author_email = self.author['email']
    self.author = ' %s <%s>' % (self.author_name, self.author_email)
else:
    self.author = ''
rbarros commented 10 years ago

Ok, I changed the email to contact.

self.author = self.view.settings().get('author', None)
self.author_name = self.author.get('name', '') if self.author else ''
self.author_contact = self.author.get('contact', '') if self.author else ''
self.author = ' %s <%s>' % (self.author_name, self.author_contact) if self.author else ''

✔ Task 1. @bug @done (14-03-06 15:48) User1 <contact1> ✘ Task 2. @change @cancelled (14-03-06 15:48) User2 <> ✔ Task 3. @change @cancelled (14-03-06 15:48) <contact3> ✔ Task 4. @change @cancelled (14-03-06 15:48)

//User1
{
    "author": {
        "name":"User1",
        "contact": "contact1"
    }
}

//User2
{
    "author": {
        "name":"User2"
    }
}

//User3
{
    "author": {
       "contact": "contact3"
    }
}

//User4
{
    "author": {
    }
}
vovkkk commented 10 years ago

@rbarros send pr, would you? convert this issue to pr or create separate one.

Also, I’ve two thoughts (feel free to ignore them):

  1. Dictionary seems redundant, of course it gives more power in matter to fiddle with programmatically (like change the order or place name in begining of line), but it seems all we need is just to place arbitrary text, so maybe str insead of dict? "author": "Vova (ping me @vovkkk)"
  2. What if user don’t want to place it everywhere, like you’ve a single file where you need this feature, but in all other files you don’t need — it’s of course not a big deal, probably not worth even thinking, but it bothers me a lil bit.
AliceBlitterCopper commented 10 years ago

hi, I like the idea of user names/contacts listed at completion entries, but dislike the config setup. Not a big deal, just questioning the overhead for this ;) How about: .) use the current log-in when completing a task .) in addition scan the file for completion entries and IF the user-name is already listed with a contact-info use that as well

So the first time you complete a task in the file just add the contact at that entry and from there on that contact would be used for other completion entries => no need for config file.

Just wanted to drop/share this idea, obviously will happily use the config file ;) Cheers and thanks for the plug in and the addition to it.

AliceBlitterCopper commented 10 years ago

btw, the small issue with config file is that it needs to be shared in addition to the todo file. That is the driver behind my idea above. cheers

vovkkk commented 10 years ago

use the current log-in when completing a task

It may vary, user may have different usernames on different machines, moreover you may create another profile on the same system e.g. for testing purpose. Scanning is not and cannot be robust either:

☐ reply to AliceBlitterCopper <reply+i-28906804-045d7d64ee3a5a18ef0bd3f39c31d7fedd49e128-1975298@reply.github.com>;
✔ buy milk @done (14-03-15 18:16) Vova (ping me @vovkkk)

We can enclose signature into something, e.g. 〈Vova〉 (not a regular parentheses), but still it doesn’t garantee anything and would increase overall complexity… Nah. I mean automation is a great thing, but sometimes it’s better to keep the thing silly simple.

AliceBlitterCopper commented 10 years ago

reg. different names on different machines: Sure it may, but how often does it? And is it really a problem? Covering all the corner cases tends to complicate things. (btw, maybe they are not corner cases for the intended usage scenarios, i don't know)

reg: finding/parsing the contact info: how about just trying to parse already completed tasks with username entries which do have the additional directly following it (via regex fe)? (in your above example either the <reply+i-28906804-045d7d64ee....> thingy IS the intended contact or it is not in which case it could be edited in place and picked up the next time I change a task)

reg: silly simple: hmmm, syncing the sublime config files between users is not, right?

Obviously there several levels and definitions of "simple" ;) Anyways, thanks for the work Cheers.

vovkkk commented 10 years ago

It doesn’t matter how often, because at some point one would face such usecase and will ask to make system-independent way — we end up to add settings entry.

how about just trying to parse already completed tasks with username entries which do have the additional directly following it (via regex fe)?

We cannot (in any way) garantee that parsed one is correct one. The whole point of the feature that file will be edited by many persons, names are not unique there might be another Vova with same username, but different email.

hmmm, syncing the sublime config files between users is not, right?

I, personally, do not consider it is a problem, I need set up working environment on new system anyway.

Obviously there several levels and definitions of "simple"

I meant in programmatic matter :smirk:

vovkkk commented 10 years ago

@rbarros ping, have no time to send pr? just tell me I’ll commit myself.