I have just done something I'm very excited about.  Given a directory name
(the variable ~assignment~ in this case) and a list of student info, search
through the directory for files whose names contain the student names, and
attach those to newly created subtrees.

Before now, manually attaching those files has been a real pain, so it's
great to have this automated! However, sometimes the name I have on file
doesn't quite match the submitted name. In particular, my Chinese students
usually have an English first name that we use in class, and a
transliterated Chinese personal name that is used in official documents
(like my class list).  I would like to first try to match the whole name,
and if that fails, attempt some kind of "fuzzy" match of the name. I'm not
sure the best way to go about it.

Any suggestions? Here is, I think, the relevant section of code (I can post
the wider context if that would be helpful). Thanks!

Matt

(mapcar (lambda (stu)
                          (let ((name (car stu))
                                (email (cdr stu))
                                )
                            (insert (format "\n** %s" name))
                            (org-todo 'todo)
                            (org-set-property "MAIL_TO" email)
                            (org-set-property "MAIL_SUBJECT"
                                              (format "Comments on %s
Assignment (%s)"

(mwp-org-get-parent-headline) name ))
                            ;; try to attach files, if possible
                            (condition-case nil
                                (let* (( afiles (directory-files
assignment  nil name)))
                                  (if afiles
                                      (dolist (f afiles)
                                        (org-attach-attach (concat
(file-name-directory (buffer-file-name)) assignment "/" f) ))
                                    (message "No files match name of %s"
name)))
                              (error (message "Unable to attach file
belonging to student")))
                            (save-excursion
                              (org-mark-subtree)
                              (org-cycle nil))
                            )) students)

Reply via email to