From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id f1h8KR9z0F7zJwAA0tVLHw (envelope-from ) for ; Fri, 29 May 2020 02:27:43 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id cLbDJB9z0F7POQAAbx9fmQ (envelope-from ) for ; Fri, 29 May 2020 02:27:43 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 21743940415 for ; Fri, 29 May 2020 02:27:43 +0000 (UTC) Received: from localhost ([::1]:57418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeUkH-0004pD-Ca for larch@yhetil.org; Thu, 28 May 2020 22:27:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeUjo-0004p4-RI for emacs-orgmode@gnu.org; Thu, 28 May 2020 22:27:12 -0400 Received: from [183.249.132.153] (port=1326 helo=localhost) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeUjn-0003hV-FY for emacs-orgmode@gnu.org; Thu, 28 May 2020 22:27:12 -0400 Received: by localhost (Postfix, from userid 1000) id CEDB5241AF5; Fri, 29 May 2020 10:27:04 +0800 (CST) References: <87sgflu2gw.fsf@gmail.com> User-agent: mu4e 1.4; emacs 28.0.50 From: stardiviner To: numbchild@gmail.com Subject: Re: [Feature] add a new org-attach dispatcher command to offline save web page In-reply-to: <87sgflu2gw.fsf@gmail.com> Date: Fri, 29 May 2020 10:27:04 +0800 Message-ID: <87mu5rscg7.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Host-Lookup-Failed: Reverse DNS lookup failed for 183.249.132.153 (deferred) Received-SPF: softfail client-ip=183.249.132.153; envelope-from=numbchild@gmail.com; helo=localhost X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/28 22:03:48 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 53 X-Spam_score: 5.3 X-Spam_bar: +++++ X-Spam_report: (5.3 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FROM=0.001, FSL_HELO_NON_FQDN_1=0.001, HELO_LOCALHOST=3.828, NML_ADSP_CUSTOM_MED=0.9, RDNS_NONE=0.793, SPF_SOFTFAIL=0.665, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: reject X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: numbchild@gmail.com Cc: Org Mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.51 X-TUID: MN77j5N7mHYV --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable I added monolith link to defcustom option docstring now. Update patch again. =20=20=20=20=20=20 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-attach.el-add-a-new-command-to-archive-web-page.patch Content-Transfer-Encoding: quoted-printable Content-Description: updated patch v3 From=206c667461b45e93059c6f801e485f7da4bfc3606c Mon Sep 17 00:00:00 2001 From: stardiviner Date: Fri, 29 May 2020 09:46:15 +0800 Subject: [PATCH] * org-attach.el: add a new command to archive web page * lisp/org-attach.el (org-attach-url-archive): A new org-attach dispatcher command to archive web page to a single file. * lisp/org-agenda.el (org-attach-url-archive-command): A customize option to specify external command for archiving web page. * lisp/org-attach.el (org-attach-url-archive-page): A command invoke external command to offline archive save web page. =2D-- lisp/org-attach.el | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/lisp/org-attach.el b/lisp/org-attach.el index 57d1360fc..80855d147 100644 =2D-- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -204,6 +204,8 @@ (defcustom org-attach-commands "Attach a file using symbolic-link method.") ((?u ?\C-u) org-attach-url "Attach a file from URL (downloading it).") + ((?U) org-attach-url-archive + "Attach an offline version of web page URL.") ((?b) org-attach-buffer "Select a buffer and attach its contents to the task.") ((?n ?\C-n) org-attach-new @@ -467,6 +469,31 @@ (defun org-attach-url (url) (let ((org-attach-method 'url)) (org-attach-attach url))) =20 +(defun org-attach-url-archive (url) + (interactive "MURL of the web page be archived to attach: \n") + (let ((org-attach-method 'archive)) + (org-attach-attach url))) + +(defcustom org-attach-url-archive-command + (file-name-nondirectory (executable-find "monolith")) + "The command used to offline archive web page. +monolith can be found here: https://github.com/Y2Z/monolith." + :type 'string + :safe #'stringp + :group 'org-attach) + +(defun org-attach-url-archive-page (url target-file) + "Save an offline archive of web page." + (pcase org-attach-url-archive-command + ("monolith" + (make-process + :name "org-attach-offline" + :command (list org-attach-url-archive-command url "-o" target-file) + :sentinel (lambda (proc event) (message "org-attach-offline finished= !")) + :buffer "*org-attach-url-archive*")) + (nil (warn "You must have a command availble for offline save web page! +Set variable `org-attach-url-archive-command'.")))) + (defun org-attach-buffer (buffer-name) "Attach BUFFER-NAME's contents to current outline node. BUFFER-NAME is a string. Signals a `file-already-exists' error @@ -504,7 +531,8 @@ (defun org-attach-attach (file &optional visit-dir meth= od) ((eq method 'cp) (copy-file file attach-file)) ((eq method 'ln) (add-name-to-file file attach-file)) ((eq method 'lns) (make-symbolic-link file attach-file)) =2D ((eq method 'url) (url-copy-file file attach-file))) + ((eq method 'url) (url-copy-file file attach-file)) + ((eq method 'archive) (org-attach-url-archive-page file attach-file= ))) (run-hook-with-args 'org-attach-after-change-hook attach-dir) (org-attach-tag) (cond ((eq org-attach-store-link-p 'attached) =2D-=20 2.26.2 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable stardiviner writes: > I attached the patch. > > I think this feature will be helpful for use who archive web page data us= ually > like me. To be more portable, I also added an defcustom option for other > external command. And use an if condition to detect whether external comm= and > available, else warning user. =2D-=20 [ stardiviner ] I try to make every word tell the meaning that I want to express. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7QcvgUHG51bWJjaGls ZEBnbWFpbC5jb20ACgkQG13xyVromsMKZwgAzXwcyjmvso0J9SBn7tQyQBxvv+PS 7WXSLVQOukurc6yDtDpeuxxNYJebXh3rp5ax+34b0lk/CXFm+GkBgeMCLGI4jduI P9EM6Q16/RzmY08/UrFY735E5iPyG7nMWBqzUrPSyPxhm7Zrg05eBUgV+eR47TbC vruhfJXbg/ZryoIes/++9RZaYBe4vWhsby/K0rdB1A5cMZVRd4eM4Oti0+6rneWY ItNkyami33lxd7EeLvSYg4dnsXPzZAYk6cFZVgSIArFuyaN1hHbkFPsaRD62oVLV Z0Ln7O+0ae6TxL2DcUcsSQdaYi6jKwmI0PRek+JirpFvPJI8j1oJHyQ8Kg== =E7f9 -----END PGP SIGNATURE----- --==-=-=--