Really funky Planner sorting

The following code sorts completed tasks in reverse-chronological
order and incomplete tasks in chronological order. This makes it
easier to see the next action (top of list) and the last action (first
completed task).

(defun sacha/planner-sort-tasks-by-date ()
  "Sort tasks by date, status and priority."
  (skip-chars-forward "#ABC")
  (let ((ch (char-before))
        status)
    (skip-chars-forward "0123456789 ")
    (setq status (char-after))
    (goto-char (line-end-position))
    (skip-chars-backward "]) ")
    (format "%1c%1c%10s"
            (cond
             ((= status ?o) ?1)
             ((= status ?X) ?3)
             ((= status ?C) ?4)
             (t ?2))
            ch
            (let ((date (or (planner-task-date (planner-current-task-info))
                            planner-sort-undated-tasks-equivalent)))
              (if (or (= status ?X)
                      (= status ?C))
                  (sacha/planner-invert-date date)
                date)))))

(defun sacha/planner-invert-date (date)
  "Reverse the date in the sorting order."
  (mapconcat (lambda (ch)
               (if (string= ch ".")
                   ch
                 (number-to-string
                  (- 9 (string-to-number ch)))))
             (split-string date "" t) ""))

pos://../emacs/planner-config.el#35188

ここのパソコンはシステムを変えることができないので何もできない。 Because the personal computer here cannot change the system, anything cannot be done.

On Technorati: , ,

Planner support for action-lock.el

action-lock.el is part
of HOWM. The following code enables Planner-style links
_anywhere_. Add it to your ~/.emacs and use M-x action-lock-mode
to turn action locking on.

(add-to-list 'action-lock-default-rules
             (list (with-planner emacs-wiki-url-or-name-regexp)
                   'planner-action-lock-follow-name-at-point))
(setq action-lock-rules action-lock-default-rules)
(defvar planner-action-lock-default-directory planner-directory "Expand files relative to this directory.")
(defun planner-action-lock-follow-name-at-point (&optional other-window)
  (let ((link-name (match-string 0))
        (base-buffer (current-buffer))
        ;; the name of the buffer that contains the link.  check
        ;; whether buffer-name is a WikiName, else make it one
        (parent-name (or (emacs-wiki-page-name)
                         (concat "[[" (buffer-name) "]]")))
        (refresh-buffer nil))
    (with-planner
      (let ((link (emacs-wiki-wiki-link-target link-name)))
        (if (emacs-wiki-wiki-url-p link)
            (emacs-wiki-browse-url link other-window)
          ;; The name list is current since the last time the buffer was
          ;; highlighted
          (let* ((base (emacs-wiki-wiki-base link-name))
                 (file (emacs-wiki-page-file base))
                 (tag  (and (not (emacs-wiki-wiki-url-p link))
                            (emacs-wiki-wiki-tag link)))
                 (find-file-function (if other-window
                                         'find-file-other-window
                                       'find-file))
                 (parent-allowed-backlink-p
                  (not (string-match
                        emacs-wiki-exclude-backlink-parent-regexp
                        parent-name)))
                 (parent-backlink (and parent-allowed-backlink-p
				   (emacs-wiki-get-current-backlink)))
                 (newbuf
                  (funcall find-file-function
                           (or file
                               (expand-file-name
                                       base
                                       (or planner-action-lock-default-directory
                                           (and (buffer-file-name)
                                                (file-name-directory
                                                 (buffer-file-name)))
                                           default-directory)))))
                 (emacs-wiki-create-backlinks
                  (and emacs-wiki-create-backlinks parent-allowed-backlink-p))
                 (make-link-p (and emacs-wiki-create-backlinks
                                   ;; insert backlink only in new files
                                   (null file)
                                   (not (string-match
                                         emacs-wiki-exclude-backlink-regexp
                                         (emacs-wiki-page-name
                                          (buffer-file-name newbuf)))))))
            (when tag
              (goto-char (point-min))
              (re-search-forward (concat "^\\.?#" tag) nil t))
            (when refresh-buffer
              (when make-link-p
                (emacs-wiki-insert-backlink parent-name parent-backlink))
              ;; todo: is with-current-buffer necessary here?
              (with-current-buffer newbuf
                (add-hook 'after-save-hook
                          'emacs-wiki-refresh-buffers-once t t)
                ;; save the new file to avoid another backlink if the
                ;; buffer is visited again before being saved
                (when (or make-link-p
                          (and (null file)
                               (not parent-allowed-backlink-p)))
                  ;; set modified status to t: pages with excluded
                  ;; parents may not be modified, but we want to save
                  ;; anyway
                  (set-buffer-modified-p t)
                  (save-buffer))))))))))

コンピュータの知識はすべての科学」にとって基本である。 Knowledge of computers is basic to all sciences.

On Technorati: ,

Emacs snippet for pmwiki attachments

(defun sacha/dired-marked-images-as-attach ()
  "Return a list of images ready to be inserted into a pmwiki page."
  (interactive)
  (kill-new (mapconcat
             (lambda (item)
               (concat "Attach:" (file-name-nondirectory item)))
             (dired-get-marked-files)
             "\n")))

On Technorati: ,

Automatically scheduling tasks onto TaskPool

(defadvice planner-create-task-from-buffer (before paul activate)
  "Automatically schedule task onto TaskPool as well as other projects."
  (if plan-page
      (unless (string-match plan-page "TaskPool")
        (setq plan-page (concat plan-page planner-multi-separator "TaskPool")))
    (setq plan-page "TaskPool")))

Here’s another snippet that will unschedule tasks from TaskPool when
you mark them completed with C-c C-x (planner-task-done). Nifty stuff,
huh?

(defadvice planner-task-done (after paul activate)
  "Remove completed tasks from the TaskPool if that still leaves them linked."
  (let ((info (planner-current-task-info)))
    (when (planner-task-link-text info)
      ;; If it is linked to TaskPool _and_ at least one other thing
      (if (string-match planner-multi-separator (planner-task-link-text info))
          (planner-multi-replan-task
           (planner-multi-make-link (planner-multi-filter-links "^TaskPool$" (planner-multi-task-link-as-list info) t)))
        ;; Else if it has a date and is linked to TaskPool
        (if (and (planner-task-date info)
                 (string= (planner-task-link info) "TaskPool"))
            (planner-replan-task nil))))))

原始的な計算機が、コンピューターの開発されるずっと以前に存在していた。 Primitive calculating machines existed long before computers were developed.

On Technorati: , ,

Adding an arbitrary extension to your planner files

Do you want all of your planner files to have a TXT extension so that
they’ll be searched by tools such as Google Desktop or Apple Spotlight?

Use the ‘rename’ tool to add .txt extensions to all of your files, or
use the following code to rename all of your planner files from a
running Planner setup:

(defun my-rename-planner-files ()
  "Rename all my planner files to .txt if they don't have that extension yet."
  (interactive)
  (mapcar
   (lambda (file)
     (unless (string-match "\\.txt$" (cdr file))
       (rename-file (cdr file) (concat (cdr file) ".txt"))
       (message "%s" (cdr file))))
   (planner-file-alist))
  (with-planner
    (emacs-wiki-refresh-file-alist)))

Then add this to your ~/.emacs before you load Planner:

(setq emacs-wiki-ignored-extensions-regexp "\\.txt")

(defadvice emacs-wiki-find-file (around extension activate)
  "Open the Emacs Wiki page WIKI by name.
If COMMAND is non-nil, it is the function used to visit the file.
If DIRECTORY is non-nil, it is the directory in which the Wiki
page will be created if it does not already exist."
  (unless (interactive-p)
    (setq wiki (cons wiki
                     (cdr (assoc wiki (emacs-wiki-file-alist))))))
  ;; At this point, `wiki' is (GIVEN-PAGE FOUND-FILE).
  (if (cdr wiki)
      (let ((buffer (funcall (or command 'find-file) (cdr wiki))))
        (if (= (prefix-numeric-value current-prefix-arg) 16)
            (with-current-buffer buffer
              (set (make-variable-buffer-local 'emacs-wiki-directories)
                   (cons (file-name-directory (cdr wiki))
                         emacs-wiki-directories))
              (set (make-variable-buffer-local 'emacs-wiki-file-alist)
                   nil)))
        buffer)
    (let* ((dirname (or directory
                        (emacs-wiki-maybe t)
                        (car emacs-wiki-directories)))
           (filename (expand-file-name (car wiki) dirname)))
      (unless (file-exists-p dirname)
        (make-directory dirname t))
      (funcall (or command 'find-file) (concat filename ".txt")))))

新しいパソコンを買うつもりで金を溜めているんだ。 I am saving money in order to buy a new personal computer.

On Technorati: , ,

sacha/planner-add-recent

(defun sacha/planner-add-recent ()
  "Add the current note to the list of recent entries, trimmed at 10."
  (interactive)
  (let* ((info (planner-current-note-info))
         (url (concat
               "http://sacha.free.net.ph/notebook/wiki/"
               (emacs-wiki-published-name (planner-note-page info))
               "#" (planner-note-anchor info))))
    (when info
      (with-current-buffer
          (find-file-noselect "/home/sacha/notebook/wiki/include/footer.inc.php")
        (goto-char (point-min))
        (when (re-search-forward "--recent--" nil t)
          (save-restriction
            (narrow-to-region (1+ (line-end-position))
                              (progn
                                (re-search-forward "--end of recent--" nil t)
                                (line-beginning-position)))
            (goto-char (point-min))
            (insert ""
                    (planner-note-title info)
                    "
\n") (forward-line 10) (delete-region (point) (point-max)) (save-buffer)))))))

../emacs/planner-config.el

そのかわいそうなネコはトラックにひかれた。 The poor cat was run over by a truck.

On Technorati: ,