From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id GE2CMWR1mWDzAAAAgWs5BA (envelope-from ) for ; Mon, 10 May 2021 20:03:16 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id CKIyLWR1mWDxWgAA1q6Kng (envelope-from ) for ; Mon, 10 May 2021 18:03:16 +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 1873A296DD for ; Mon, 10 May 2021 20:03:16 +0200 (CEST) Received: from localhost ([::1]:46678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgAFP-000377-8Q for larch@yhetil.org; Mon, 10 May 2021 14:03:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgAEG-00036e-23 for emacs-orgmode@gnu.org; Mon, 10 May 2021 14:02:04 -0400 Received: from mailrelay3-3.pub.mailoutpod1-cph3.one.com ([46.30.212.12]:18122) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgAED-0002Gs-9I for emacs-orgmode@gnu.org; Mon, 10 May 2021 14:02:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntumwa-nziza.com; s=20191106; h=content-transfer-encoding:content-type:mime-version:message-id:date:subject: cc:to:from:from; bh=EEWKZySGQjAXzBlWyIsQNq34OHXi/QnlQhBQ85Y95o4=; b=CkBl/BcbP9bvFvth9yv2XcaLhJ+vMCehZqwGNMre0bitQsxeSacIKjZmQGXsK+YCm9q19Stni5E0w 2TmS7oTQvgqaLT8ZVSYOi2WNwZZVUBmblUd4/CI7+Ywd2e1uoJEIT2gBl2YS0Hjfb3+n8JJPhwubls pCzfa4mLgvr+EajqP5lvfl31ls8cH9sYc6hu6YNp367tFmuTI5IRtdoK4XLvFIgTaKm2GsDFinkwYK TKSWWELKnSKAT/IuuK6zH+DFhO0WFb7p2t8kh1xrsIk7Kob856Mbvs8GoCRud0/1vwlw5x41XJyTV7 mesz/nmD7spOiMuIoNyj2AktwfEergg== X-HalOne-Cookie: 8cc79b50efdc033afe6851dbfccef433d1c60ef8 X-HalOne-ID: ceb45af2-b1b9-11eb-8cd5-d0431ea8bb03 Received: from localhost (p5dd83b85.dip0.t-ipconnect.de [93.216.59.133]) by mailrelay3.pub.mailoutpod1-cph3.one.com (Halon) with ESMTPSA id ceb45af2-b1b9-11eb-8cd5-d0431ea8bb03; Mon, 10 May 2021 18:01:56 +0000 (UTC) User-agent: mu4e 1.4.15; emacs 28.0.50 From: =?utf-8?Q?Aim=C3=A9?= Bertrand To: emacs-orgmode@gnu.org Cc: Subject: [PATCH] Link handling for qutebrowser org-mac-link.el Date: Mon, 10 May 2021 20:01:55 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Received-SPF: none client-ip=46.30.212.12; envelope-from=aime.bertrand@ntumwa-nziza.com; helo=mailrelay3-3.pub.mailoutpod1-cph3.one.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.248, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620669796; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=SPVlDgghkscM79t/pzydpu4fCT+gie2MMVfuftyorUM=; b=AuDg2Z+pfhecoEEu/P2MR0L2tqO+JipsUxgwFxG43OsYUi3iR7EwxZV05HwAkEHbu2he5B CA8lrMzSt3E2OLWN9qlVKkVLgYKiea0BE8lseA5mGylkFNyeo0HQg9I+Z3AVvgk2zPGcaM Vz7bihwxUEivt1Rr6y7FsVf9q1qk24c7021i0WX2ek8/gXayYYYhCoAMx+qrlhCRDTHCCA 6Os/pDTgsIcnXMTAYDkSw+3Kdgf96/ENgZVq7uK+N/mIFGFuLOripr+aoK3/LBnB6NnDnM P2VydtFmLvOpuF/lpLrRBZGmvqyUBrOE57Rh8yUqEtwtOIFfSVtScxMAEemj9w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620669796; a=rsa-sha256; cv=none; b=uEFkgmI4haJjWqcTD27+pncCviD42ReLOOtPFWJyOds6nh06TiFsMaMiUvghtlxJIgpLed rY6UwB8vSC4yAnOOB76987Pwympyj9+rb2IjtEWaYX7l1dGmAlsWRQbfSRaLZiVk3btHw/ 9vnMG2NK2+7ybLINpJvpL9mS6iVzZkveXm8iHhy58d4B/k724E12JwXQG6yw6LasGyLNlc hNp/X1W8/M/3X3+zD82on9a5e0aOeSzX0OWR/y735UoPwLFSvsV2MWL+oemQL9H8io+NsR Bn50T59I/coUJ1i9aHgS1Hl5GaraTHBHr+HiQaPLx93bmRnwf0favLjSACBrAA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=ntumwa-nziza.com header.s=20191106 header.b="CkBl/Bcb"; 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-Migadu-Spam-Score: -1.45 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=ntumwa-nziza.com header.s=20191106 header.b="CkBl/Bcb"; dmarc=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-Migadu-Queue-Id: 1873A296DD X-Spam-Score: -1.45 X-Migadu-Scanner: scn0.migadu.com X-TUID: 69tw2Hayeo8p Hi everyone, hope to have done this right as a first time. Work on a Mac with qutebrowser and thought the following patch=20 would be helpful. Salut Aim=C3=A9 Bertrand modified lisp/org-mac-link.el @@ -218,6 +218,12 @@ :group 'org-mac-link :type 'string) +(defcustom org-mac-grab-qutebrowser-app-p t + "Add menu option [q]utebrowser to grab links from=20 qutebrowser.app." + :tag "Grab qutebrowser.app links" + :group 'org-mac-link + :type 'boolean) + ;; In mac.c, removed in Emacs 23. (declare-function do-applescript "org-mac-message" (script)) @@ -254,7 +260,8 @@ When done, go grab the link, and insert it at=20 point." ("e" "evernote" org-mac-evernote-note-insert-selected=20 ,org-mac-grab-Evernote-app-p) ("t" "ogether" org-mac-together-insert-selected=20 ,org-mac-grab-Together-app-p) ("S" "kim" org-mac-skim-insert-page=20 ,org-mac-grab-Skim-app-p) - ("A" "crobat" org-mac-acrobat-insert-page=20 ,org-mac-grab-Acrobat-app-p))) + ("A" "crobat" org-mac-acrobat-insert-page=20 ,org-mac-grab-Acrobat-app-p) + ("q" "utebrowser" org-mac-qutebrowser-insert-frontmost-url=20 ,org-mac-grab-qutebrowser-app-p))) (menu-string (make-string 0 ?x)) input) @@ -1013,6 +1020,52 @@ list of message:// links to flagged mail=20 after heading." (org-insert-heading nil t) (insert org-heading "\n" (org-mac-message-get-links "f")))))) + +;; Handle links from qutebrowser.app + +(defun org-as-mac-qutebrowser-get-frontmost-url () + (let ((result + (do-applescript + (concat + "set oldClipboard to the clipboard\n" + "set frontmostApplication to path to frontmost=20 application\n" + "tell application \"qutebrowser\"\n" + " activate\n" + " delay 0.15\n" + " tell application \"System Events\"\n" + " keystroke \"y\"\n" + " keystroke \"y\"\n" + " end tell\n" + " delay 0.15\n" + " set theUrl to the clipboard\n" + " set the clipboard to oldClipboard\n" + " delay 0.15\n" + " tell application \"System Events\"\n" + " keystroke \"y\"\n" + " keystroke \"T\"\n" + " end tell\n" + " delay 0.15\n" + " set theTitle to the clipboard\n" + " set the clipboard to oldClipboard\n" + " set theResult to (get theUrl) & \"::split::\" &=20 (get theTitle)\n" + "end tell\n" + "activate application (frontmostApplication as=20 text)\n" + "set links to {}\n" + "copy theResult to the end of links\n" + "return links as string\n")))) + (car (split-string result "[\r\n]+" t)))) + +;;;###autoload +(defun org-mac-qutebrowser-get-frontmost-url () + (interactive) + (message "Applescript: Getting qutebrowser url...") + (org-mac-paste-applescript-links=20 (org-as-mac-qutebrowser-get-frontmost-url))) + +;;;###autoload +(defun org-mac-qutebrowser-insert-frontmost-url () + (interactive) + (insert (org-mac-qutebrowser-get-frontmost-url))) + (provide 'org-mac-link)