summary refs log tree commit diff stats
path: root/lisp/acdw.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/acdw.el')
-rw-r--r--lisp/acdw.el36
1 files changed, 29 insertions, 7 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index 2be0c4e..30cf8af 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -313,16 +313,38 @@ With a prefix argument, run git pull on the repo first."
313(defun acdw/copy-region-plain (start end) 313(defun acdw/copy-region-plain (start end)
314 "Copy a region to clipboard, removing all Org formatting." 314 "Copy a region to clipboard, removing all Org formatting."
315 (interactive "*r") 315 (interactive "*r")
316 (let ((s (buffer-substring-no-properties start end))) 316 (let ((s (buffer-substring-no-properties start end))
317 (extracted-heading (when (derived-mode-p 'org-mode)
318 (acdw/org-extract-heading-text))))
317 (with-temp-buffer 319 (with-temp-buffer
318 (insert s) 320 (insert s)
319 (let ((sentence-end-double-space nil)) 321 (let ((sentence-end-double-space nil))
320 (unfill-region (point-min) (point-max))) 322 ;; Remove org stuff
321 (copy-region-as-kill (point-min) (point-max))) 323 (when extracted-heading ; Replace org heading with plaintext
322 (when (called-interactively-p 'interactive) 324 (goto-char (point-min))
323 (indicate-copied-region)) 325 (kill-line)
324 (setq deactivate-mark t) 326 (insert extracted-heading))
325 nil)) 327 (replace-regexp org-property-drawer-re "") ;Delete properties
328 (replace-regexp org-logbook-drawer-re "") ;Delete logbook
329 (replace-regexp org-list-full-item-re "
330\4")
331 ;; Re-fill text for clipboard
332 (unfill-region (point-min) (point-max))
333 (flush-lines "^$" (point-min) (point-max)))
334 ;; Copy buffer
335 (copy-region-as-kill (point-min) (point-max))))
336 (when (called-interactively-p 'interactive)
337 (indicate-copied-region))
338 (setq deactivate-mark t)
339 nil)
340
341(defun acdw/org-extract-heading-text ()
342 (let ((heading (org-no-properties (org-get-heading t t t t))))
343 (message
344 (replace-regexp-in-string org-link-bracket-re
345 (lambda (match)
346 (match-string-no-properties 2 match))
347 heading))))
326 348
327(defun acdw/dir (&optional file make-directory) 349(defun acdw/dir (&optional file make-directory)
328 "Place Emacs files in one place. 350 "Place Emacs files in one place.