Disclaimer

The content of this blog is my personal opinion only. Although I am an employee - currently of Nvidia, in the past of other companies such as Iagination Technologies, MIPS, Intellectual Ventures, Intel, AMD, Motorola, and Gould - I reveal this only so that the reader may account for any possible bias I may have towards my employer's products. The statements I make here in no way represent my employer's position, nor am I authorized to speak on behalf of my employer. In fact, this posting may not even represent my personal opinion, since occasionally I play devil's advocate.

See http://docs.google.com/View?id=dcxddbtr_23cg5thdfj for photo credits.

Tuesday, September 10, 2013

org-capture ... org-get-x-clipboard very slow

I enjoy org-mode, but have found "capture", aka org-capture, too slow for general use.

This has been on my to-investigate list for months, and I finally got around to it.

Problem



^c-c-t (my todo capture template) takes 10 seconds or so, no matter what the template

elp-instrument-package org

      (elp-instrument-package(quote org))


Profile

Function name                                                 Call count Elapsed Time   Average Time
org-capture                                                   1           7.4114240000  7.4114240000
org-capture-fill-template                                     1           6.6733817000  6.6733817000
org-get-x-clipboard                                           4           6.6563808     1.6640952
org-get-x-clipboard-compat                                    4           6.6563808     1.6640952
org-capture-select-template                                   1           0.7310417999  0.7310417999
org-mks                                                       1           0.7310417999  0.7310417999
org-mode                                                      1           0.0130008     0.0130008
org-install-agenda-files-menu                                 1           0.0060004000  0.0060004000
org-set-regexps-and-options                                   1           0.0060003000  0.0060003000

Basically, org-get-x-clipboard is almost all of the time.

(Verified by nulling out org-gert-x-clipboard.)




Suboptimal:   I was not asking for any template substitutions.  But org-capture-fill-template calculates every variable, whether needed or not


(defun org-capture-fill-template (&optional template initial annotation)
  "Fill a template and return the filled template as a string.
The template may still contain \"%?\" for cursor positioning."
  (setq template (or template (org-capture-get :template)))
  (when (stringp initial)
    (setq initial (org-no-properties initial))
    (remove-text-properties 0 (length initial) '(read-only t) initial))
  (let* ((buffer (org-capture-get :buffer))
(file (buffer-file-name (or (buffer-base-buffer buffer) buffer)))
(ct (org-capture-get :default-time))
(dct (decode-time ct))
(ct1
 (if (< (nth 2 dct) org-extend-today-until)
     (encode-time 0 59 23 (1- (nth 3 dct)) (nth 4 dct) (nth 5 dct))
   ct))
(plist-p (if org-store-link-plist t nil))
(v-c (and (> (length kill-ring) 0) (current-kill 0)))
(v-x (or (org-get-x-clipboard 'PRIMARY)
 (org-get-x-clipboard 'CLIPBOARD)
 (org-get-x-clipboard 'SECONDARY)))

(v-t (format-time-string (car org-time-stamp-formats) ct))
(v-T (format-time-string (cdr org-time-stamp-formats) ct))
(v-u (concat "[" (substring v-t 1 -1) "]"))
(v-U (concat "[" (substring v-T 1 -1) "]"))

However, although I think that I am not using a template, I get

Clipboard pasted as level 1 subtree


Workaround

Making org-get-x-clipboard empty

makes capture very fast - 0.036 seconds as reportted by elp

Configuration

GNU Emacs 24.3.1

org-mode 7.8./03

CYGWIN_NT-6.1-WOW64 glew-tablet 1.7.17(0.262/5/3) 2012-10-19 14:39 i686 Cygwin


Out-of-date ... updating ...




No comments: