From c3d1d6aa9369a64374facd95b353035d934a92e3 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sun, 22 Dec 2024 13:12:59 +0100 Subject: [PATCH] update ox-clip Signed-off-by: Andreas Gerler --- .../ox-clip-autoloads.el | 41 -------- elpa/ox-clip-20220117.1909/ox-clip-pkg.el | 15 --- .../ox-clip-autoloads.el | 51 ++++++++++ elpa/ox-clip-20240310.1513/ox-clip-pkg.el | 11 +++ .../ox-clip.el | 95 ++++++++++++++----- elpa/ox-clip-readme.txt | 22 ----- 6 files changed, 131 insertions(+), 104 deletions(-) delete mode 100644 elpa/ox-clip-20220117.1909/ox-clip-autoloads.el delete mode 100644 elpa/ox-clip-20220117.1909/ox-clip-pkg.el create mode 100644 elpa/ox-clip-20240310.1513/ox-clip-autoloads.el create mode 100644 elpa/ox-clip-20240310.1513/ox-clip-pkg.el rename elpa/{ox-clip-20220117.1909 => ox-clip-20240310.1513}/ox-clip.el (85%) delete mode 100644 elpa/ox-clip-readme.txt diff --git a/elpa/ox-clip-20220117.1909/ox-clip-autoloads.el b/elpa/ox-clip-20220117.1909/ox-clip-autoloads.el deleted file mode 100644 index ceddf063..00000000 --- a/elpa/ox-clip-20220117.1909/ox-clip-autoloads.el +++ /dev/null @@ -1,41 +0,0 @@ -;;; ox-clip-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- -;; -;;; Code: - -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) - - -;;;### (autoloads nil "ox-clip" "ox-clip.el" (0 0 0 0)) -;;; Generated autoloads from ox-clip.el - -(autoload 'ox-clip-formatted-copy "ox-clip" "\ -Export the selected region to HTML and copy it to the clipboard. -R1 and R2 define the selected region. - -\(fn R1 R2)" t nil) - -(autoload 'ox-clip-image-to-clipboard "ox-clip" "\ -Copy the image file or latex fragment at point to the clipboard as an image. -SCALE is a numerical -prefix (default=`ox-clip-default-latex-scale') that determines -the size of the latex image. It has no effect on other kinds of -images. Currently only works on Linux. - -\(fn &optional SCALE)" t nil) - -(register-definition-prefixes "ox-clip" '("ox-clip-")) - -;;;*** - -;;;### (autoloads nil nil ("ox-clip-pkg.el") (0 0 0 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; ox-clip-autoloads.el ends here diff --git a/elpa/ox-clip-20220117.1909/ox-clip-pkg.el b/elpa/ox-clip-20220117.1909/ox-clip-pkg.el deleted file mode 100644 index 70e5025e..00000000 --- a/elpa/ox-clip-20220117.1909/ox-clip-pkg.el +++ /dev/null @@ -1,15 +0,0 @@ -(define-package "ox-clip" "20220117.1909" "Cross-platform formatted copying for org-mode" - '((org "8.2") - (htmlize "0")) - :commit "ff117cf3c619eef12eccc0ccbfa3f11adb73ea68" :authors - '(("John Kitchin" . "jkitchin@andrew.cmu.edu")) - :maintainers - '(("John Kitchin" . "jkitchin@andrew.cmu.edu")) - :maintainer - '("John Kitchin" . "jkitchin@andrew.cmu.edu") - :keywords - '("org-mode") - :url "https://github.com/jkitchin/ox-clip") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/ox-clip-20240310.1513/ox-clip-autoloads.el b/elpa/ox-clip-20240310.1513/ox-clip-autoloads.el new file mode 100644 index 00000000..5c725bf6 --- /dev/null +++ b/elpa/ox-clip-20240310.1513/ox-clip-autoloads.el @@ -0,0 +1,51 @@ +;;; ox-clip-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + +;;; Code: + +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + + + +;;; Generated autoloads from ox-clip.el + +(autoload 'ox-clip-get-command "ox-clip" "\ +Get the command form OPTIONS. +OPTIONS is one of `ox-clip-w32-cmd', `ox-clip-osx-cmd', or +`ox-clip-linux-cmd'. Those may be a string, or a list of +candidates to choose from. + +(fn OPTIONS)") +(autoload 'ox-clip-formatted-copy "ox-clip" "\ +Export the selected region to HTML and copy it to the clipboard. +R1 and R2 define the selected region. + +If SUBTREEP (interactively, the prefix argument) is non-nil then +export the current `org-mode' subtree, including hidden content. + +(fn R1 R2 &optional SUBTREEP)" t) +(autoload 'ox-clip-image-to-clipboard "ox-clip" "\ +Copy the image file or latex fragment at point to the clipboard as an image. +SCALE is a numerical +prefix (default=`ox-clip-default-latex-scale') that determines +the size of the latex image. It has no effect on other kinds of +images. Currently only works on Linux. + +(fn &optional SCALE)" t) +(register-definition-prefixes "ox-clip" '("ox-clip-")) + +;;; End of scraped data + +(provide 'ox-clip-autoloads) + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; no-native-compile: t +;; coding: utf-8-emacs-unix +;; End: + +;;; ox-clip-autoloads.el ends here diff --git a/elpa/ox-clip-20240310.1513/ox-clip-pkg.el b/elpa/ox-clip-20240310.1513/ox-clip-pkg.el new file mode 100644 index 00000000..103e6597 --- /dev/null +++ b/elpa/ox-clip-20240310.1513/ox-clip-pkg.el @@ -0,0 +1,11 @@ +;; -*- no-byte-compile: t; lexical-binding: nil -*- +(define-package "ox-clip" "20240310.1513" + "Cross-platform formatted copying for org-mode." + '((org "8.2") + (htmlize "0")) + :url "https://github.com/jkitchin/ox-clip" + :commit "a549cc8e1747beb6b7e567ffac27e31ba45cb8e8" + :revdesc "a549cc8e1747" + :keywords '("org-mode") + :authors '(("John Kitchin" . "jkitchin@andrew.cmu.edu")) + :maintainers '(("John Kitchin" . "jkitchin@andrew.cmu.edu"))) diff --git a/elpa/ox-clip-20220117.1909/ox-clip.el b/elpa/ox-clip-20240310.1513/ox-clip.el similarity index 85% rename from elpa/ox-clip-20220117.1909/ox-clip.el rename to elpa/ox-clip-20240310.1513/ox-clip.el index 72dd1762..2298ad4f 100644 --- a/elpa/ox-clip-20220117.1909/ox-clip.el +++ b/elpa/ox-clip-20240310.1513/ox-clip.el @@ -1,11 +1,11 @@ - ;;; ox-clip.el --- Cross-platform formatted copying for org-mode -;; Copyright(C) 2016-2021 John Kitchin +;; Copyright(C) 2016-2024 John Kitchin ;; Author: John Kitchin ;; URL: https://github.com/jkitchin/ox-clip -;; Version: 0.3 +;; Package-Version: 20240310.1513 +;; Package-Revision: a549cc8e1747 ;; Keywords: org-mode ;; Package-Requires: ((org "8.2") (htmlize "0")) @@ -65,27 +65,33 @@ (expand-file-name "html-clip-w32.py" (file-name-directory (or load-file-name (locate-library "ox-clip"))))) - "Absolute path to html-clip-w32.py." + "Usually an absolute path to html-clip-w32.py. +Could also be an alist of (target . cmd)" :group 'ox-clip - :type 'string) + :type '(choice string (list (cons string string)))) (defcustom ox-clip-osx-cmd - "textutil -inputencoding UTF-8 -stdin -format html -convert rtf -stdout | pbcopy" - "Command to copy formatted text on osX." - ;; This may work better on Chrome and Slack - ;; "hexdump -ve '1/1 \"%.2x\"' | xargs printf \"set the clipboard to {text:\\\" \\\", «class HTML»:«data HTML%s»}\" | osascript -" + '(("default" . "textutil -inputencoding UTF-8 -stdin -format html -convert rtf -stdout | pbcopy") + ;; This may work better on Chrome and Slack + ("html" . "hexdump -ve '1/1 \"%.2x\"' | xargs printf \"set the clipboard to {text:\\\" \\\", «class HTML»:«data HTML%s»}\" | osascript -") + ;; This may work better on GitHUB + ("markdown" . "pandoc -f html -t markdown - | grep -v \"^:::\" | sed 's/{#.*}//g' | pbcopy")) + "Possible commands to copy formatted text on osX. +This can be a string, or an alist of (target . cmd)." :group 'ox-clip - :type 'string) + :type '(choice string (list (cons string string)))) (defcustom ox-clip-linux-cmd "xclip -verbose -i \"%f\" -t text/html -selection clipboard" "Command to copy formatted text on linux. -You must include %f. It will be converted to a generated -temporary filename later." +This can be a string, or an alist of (target . cmd). You must +include %f in hte command. It will be converted to a generated +temporary filename at run-time." :group 'ox-clip - :type 'string) + :type '(choice string (list (cons string string)))) + (defvar ox-clip-w32-py "#!/usr/bin/env python # Adapted from http://code.activestate.com/recipes/474121-getting-html-from-the-windows-clipboard/ @@ -359,6 +365,7 @@ if __name__ == '__main__': " "Windows Python Script for copying formatted text.") + (defcustom ox-clip-default-latex-scale 3 "Default scale to use in `org-format-latex-options'. Used when creating preview images for copying." @@ -377,15 +384,45 @@ Used when creating preview images for copying." ;;;###autoload -(defun ox-clip-formatted-copy (r1 r2) +(defun ox-clip-get-command (options) + "Get the command form OPTIONS. +OPTIONS is one of `ox-clip-w32-cmd', `ox-clip-osx-cmd', or +`ox-clip-linux-cmd'. Those may be a string, or a list of +candidates to choose from." + (if (stringp options) + options + (cdr (assoc (completing-read "Copy to: " options) options)))) + + +;;;###autoload +(defun ox-clip-formatted-copy (r1 r2 &optional subtreep) "Export the selected region to HTML and copy it to the clipboard. -R1 and R2 define the selected region." - (interactive "r") - (copy-region-as-kill r1 r2) +R1 and R2 define the selected region. + +If SUBTREEP (interactively, the prefix argument) is non-nil then +export the current `org-mode' subtree, including hidden content." + (interactive (list + ;; This seems wonky, but it turns out you can get non-selected + ;; regions from these when the region is not active. Using "rP" + ;; leads to false selections imo. I think this is less + ;; surprising. + (when (region-active-p) (region-beginning)) + (when (region-active-p) (region-end)) + current-prefix-arg)) + + ;; Put a copy in the kill ring in case you want it in Emacs. + (if (null subtreep) + (copy-region-as-kill r1 r2) + (org-mark-subtree) + (org-copy-subtree)) + (if (equal major-mode 'org-mode) (save-window-excursion (let* ((org-html-with-latex 'dvipng) - (buf (org-export-to-buffer 'html "*Formatted Copy*" nil nil t t)) + ;; by default we only copy visible stuff, i.e. it should look like you see + ;; but if you choose subtreep, we copy it all + (visible-only (not subtreep)) + (buf (org-export-to-buffer 'html "*Formatted Copy*" nil subtreep visible-only t)) (html (with-current-buffer buf (buffer-string)))) (cond ((eq system-type 'windows-nt) @@ -393,13 +430,13 @@ R1 and R2 define the selected region." (shell-command-on-region (point-min) (point-max) - ox-clip-w32-cmd))) + (ox-clip-get-command ox-clip-w32-cmd)))) ((eq system-type 'darwin) (with-current-buffer buf (shell-command-on-region (point-min) (point-max) - ox-clip-osx-cmd))) + (ox-clip-get-command ox-clip-osx-cmd)))) ((eq system-type 'gnu/linux) ;; For some reason shell-command on region does not work with xclip. (let* ((tmpfile (make-temp-file "ox-clip-" nil ".html" @@ -407,8 +444,10 @@ R1 and R2 define the selected region." (proc (apply 'start-process "ox-clip" "*ox-clip*" (split-string-and-unquote - (format-spec ox-clip-linux-cmd - `((?f . ,tmpfile))) " ")))) + (format-spec + (ox-clip-get-command ox-clip-linux-cmd) + `((?f . ,tmpfile))) + " ")))) (set-process-query-on-exit-flag proc nil)))) (kill-buffer buf))) ;; Use htmlize when not in org-mode. @@ -420,21 +459,23 @@ R1 and R2 define the selected region." (shell-command-on-region (point-min) (point-max) - ox-clip-w32-cmd))) + (ox-clip-get-command ox-clip-w32-cmd)))) ((eq system-type 'darwin) (with-temp-buffer (insert html) (shell-command-on-region (point-min) (point-max) - ox-clip-osx-cmd))) + (ox-clip-get-command ox-clip-osx-cmd)))) ((eq system-type 'gnu/linux) (let* ((tmpfile (make-temp-file "ox-clip-" nil ".html" html)) (proc (apply 'start-process "ox-clip" "*ox-clip*" (split-string-and-unquote - (format-spec ox-clip-linux-cmd - `((?f . ,tmpfile))) " ")))) + (format-spec + (ox-clip-get-command ox-clip-linux-cmd) + `((?f . ,tmpfile))) + " ")))) (set-process-query-on-exit-flag proc nil))))))) @@ -443,6 +484,7 @@ R1 and R2 define the selected region." "Get overlay at point. A helper to avoid dependency on ov.el." (car (overlays-at (point)))) + ;;;###autoload (defun ox-clip-image-to-clipboard (&optional scale) "Copy the image file or latex fragment at point to the clipboard as an image. @@ -507,6 +549,7 @@ images. Currently only works on Linux." image-file))))) (message "Copied %s" image-file))) + (provide 'ox-clip) ;;; ox-clip.el ends here diff --git a/elpa/ox-clip-readme.txt b/elpa/ox-clip-readme.txt deleted file mode 100644 index 01c2bd3f..00000000 --- a/elpa/ox-clip-readme.txt +++ /dev/null @@ -1,22 +0,0 @@ -This module copies selected regions in org-mode as formatted text on the -clipboard that can be pasted into other applications. When not in org-mode, -the htmlize library is used instead. - -For Windows the html-clip-w32.py script will be installed. It works pretty -well, but I noticed that the hyperlinks in the TOC to headings don't work, -and strike-through doesn't seem to work. I have no idea how to fix either -issue. - -Mac OSX needs textutils and pbcopy, which should be part of the base install. - -Linux needs a relatively modern xclip, preferrably a version of at least -0.12. https://github.com/astrand/xclip - -The main command is `ox-clip-formatted-copy' that should work across -Windows, Mac and Linux. By default, it copies as html. - -Note: Images/equations may not copy well in html. Use `ox-clip-image-to-clipboard' to -copy the image or latex equation at point to the clipboard as an image. The -default latex scale is too small for me, so the default size for this is set -to 3 in `ox-clip-default-latex-scale'. This overrides the settings in -`org-format-latex-options'. -- 2.47.3