From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id sMp2BO+TumQOEAAASxT56A (envelope-from ) for ; Fri, 21 Jul 2023 16:19:27 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id INx9A++TumS0rAAAG6o9tA (envelope-from ) for ; Fri, 21 Jul 2023 16:19:27 +0200 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 89D7651A0C for ; Fri, 21 Jul 2023 16:19:26 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=live.com header.s=selector1 header.b=fP7jtfWu; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=live.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1689949166; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=zxehJHDMdm3c6uJoIzOh3B1WvdMAaAABJWUHAnayB0s=; b=IMnZFNzCQ6AzyvvcT5zkEtiTtuh8CAUYobEypLwnNpTYmReEbipTitKCIScIBW6HQCpekc DIQkJ132cw14uLVsRg9cnIhL0gRBUKTmSLanRKiU+0vEtdl9k2iD3prmApl1sYnSkd8ZMZ NOttaKD0v5cOkUV+i/D/j5XlAOmUzCgqnE0rBJISdxGKOe4dQhdH3iC02Rqnd4rYHN19Dj VfDpN+rw7Pcu3LmFh0iCKusR1vf+j6fd4gauRIfQKqOBFRGxKkLEm4x1ZE9RDw1ax5o3+7 Q/WLSkzQOKaFeGvQ3izeHcT1CtI9pUilJMTNr/cFBVJ8ZpNzMiV5U1JQmvfnyg== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1689949166; a=rsa-sha256; cv=pass; b=GuxPppoBum6St2TpRkNtDX+LY0qzyYrcVFkoB7CvHLdQBbhYuBqUeneiqV6qydWKY6m5eI mMfkTDMRQf7/+Vo3hd35yqj+O76TTge/wL7Oj9e40Axc+KIwPhO+kLL+Shknd/FKnlgRwE aBEj3zwAs7BkHXtmYDb2WlkecXuW7oRFNEPDbmq8Gso+dU6aUzJ2JbkAoeINoeIWii87Ir aCXXAoDNBjxtYsSkTa4oslH3fYtpYBfNPrz7Po7KrI5LY0IxUzNLo2BKmPpb0zfOz9gcMx CQs3dnYdpjELQiIAhlZyyWzzzR2zVrHhaw7h0xp9HckNQ9pYBnYjpvIewIyOWg== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=live.com header.s=selector1 header.b=fP7jtfWu; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=live.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMqxi-0002XI-Rp; Fri, 21 Jul 2023 10:18:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMqxg-0002X5-Tg for emacs-orgmode@gnu.org; Fri, 21 Jul 2023 10:18:28 -0400 Received: from mail-db5eur02olkn2056.outbound.protection.outlook.com ([40.92.50.56] helo=EUR02-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMqxe-0003iq-Bt for emacs-orgmode@gnu.org; Fri, 21 Jul 2023 10:18:28 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JFCdpsNFS9oyn8zab+2FgKwzEhLriAB4j54ruQK27AGRlGo9Z0NKYwZb9cgvdxCLHttAmoyoUQMi8Bl7odFbXt/xa6FfvvIJndRVb1pLhxkWz+Lv3aKabNFoSUxPVIRQglIcsqXCpBj0E02PhvqcnpsMdxSGWzEbDir+3hY8tGMSzCVZPC6iuWOXLHYvD9lmEFlhYALGl8hYNXZfWXCJooW6zFfow/vJ/VfbWnvCFyev8MFQig5IBf1QM3rtBf0IPkPNcRTx7AYYW1d0cb7dw5W/dsy35ukxCt4OnVTFADaq77rAa6ZV0kZvKAjGhtTjdBd2oxqAboaHw1c/paBx8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zxehJHDMdm3c6uJoIzOh3B1WvdMAaAABJWUHAnayB0s=; b=MjbDi84KjvTIYDiTQD1hCJtas0LS4i4Ba1zjVq8GocjPCSX+vFf6iCVa5RZoDhBTdokgw2a/yHroO6n8PH0CnpzsltRV/QQ6AB1KP2QvMbxdOFwJBobdcUCk363bl6unpodPe2zsEST9ycohlYkfPsMH7vs8gmSkd4pdiCfNxiJ2lIeNmuIR5a9MXrR2yzrCym8qTB3w4jUcTBVMZ2qItIPXxkiMgkyeYdmjRMRsLsAPXbh07xredPu4cXn6No1Bsvbr/+cT9QZ/Ug7MvjJJrZmncuXyIWfE0eBvGBuyDedyA+M/SyQiWsMa1opyd8/Q2Ys9gnyBgK1PQWX0msgkhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zxehJHDMdm3c6uJoIzOh3B1WvdMAaAABJWUHAnayB0s=; b=fP7jtfWusTEJSORgl6yI2b0YDq24ThFg8zQErooSwKIEDYgVefU9Hl56d6fD9yEo7zyfl6oTzxqxtdplfJzjOGuCfF1wAAYNqgftG7iq6qVKbLozDZ/Db8pTPZ6/3sx0Qsbw5lrHDlmp0APfV05RBD/UPm38l/jjCdELQ9GOpYaoDHrAD0PNwhIKoiE0n7TnyzkApAKnCj9XfmkI2wECLn4yQb9KTVqL7yOQreWplaMWNwcoQ2/w8FWJyOecDcyWJQP56p7kkCz8DNvDR2L0ov4pehWTtzUCgmixA0+JeavSLAvO0YDQuwTJq3FMNBXvFi2SxhpK+hRGmxvtm7fpQw== Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by AM0PR09MB3907.eurprd09.prod.outlook.com (2603:10a6:208:1a1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.28; Fri, 21 Jul 2023 14:18:23 +0000 Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::df56:b1b1:64b1:6122]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::df56:b1b1:64b1:6122%7]) with mapi id 15.20.6609.024; Fri, 21 Jul 2023 14:18:23 +0000 From: Arthur Miller To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: Is there a better (built-in) way to insert an org link with title as description? In-Reply-To: <87351irjad.fsf@localhost> (Ihor Radchenko's message of "Thu, 20 Jul 2023 10:04:10 +0000") References: <87351irjad.fsf@localhost> Date: Fri, 21 Jul 2023 16:18:22 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Content-Type: text/plain X-TMN: [YqZfXhCtqFlGY0QmW1E+k9i20w4i0Y0LkSpK24ms8Zs=] X-ClientProxiedBy: BE1P281CA0169.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:66::15) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <87fs5hwdox.fsf@live.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR09MB4977:EE_|AM0PR09MB3907:EE_ X-MS-Office365-Filtering-Correlation-Id: da545404-774f-4858-589b-08db89f55793 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FcUxP8Ea1PrengPl3G8eOc2e+HaMtCNOR2cgREYKgfDY6UNmSwVVh1ET8wY20V1dCnCbeF/oXphe6FhBoMhNg2DLWnm/GoJYycLZejejHTt7SgtL3zrVPExGbX9V1lWig0GdTnVA16k+YtpT1y5pJei8yRCzxJ7DNCpfzy/c+w8TUKlj/G+idy8mvWICzKpbVIUjeQmmTkli7A++rF6vJZ1qWDqISzWVadmMvENArpjRDi8qesaS09Ktst0Db2C7baU/f0s7VF0+tMea9KXLXBOlI5cgBLSSKaacC0sPJ2U/cAAaCoCFvEZj8TTxIYkyjQZZRhakjXRbUaPozfk9xVsL95Rh6sqtblMPGGChnbpHp+M2XGY6F8qjDyNgrMC4eDJh9Y4l15Yo8eLHJKFYSYGl2B5MeW9HpYwVWYgDxUbec9VxMYN59DryM4HFPZv4R/HBieO96Ka+LmkhHfoNGOhYgUxIeDARsJG4eYf+JMwgVVfEelNSskKR8NgzKEXJ1BMVPBRwHA7zzXujcCVTsM7Bqs2oc8TE0uod6KylCvs= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?wjBVD0EnBG97OhlyW3esJiqxbxkxmECxYJGFpbE3oodFVnaJiT805tbMD9Yw?= =?us-ascii?Q?mD0B4AHRxyTpkmUOBxwQb9dk9oxPInUIq8CVwYIkGuJmEBiiiK3q5cOvSQe1?= =?us-ascii?Q?p0ogHg5xWvO+eqMnOW3PZVoYR1s4DfsIhc4oyb52cMWu5275XFFGmTJaWPDs?= =?us-ascii?Q?VXdaMx/e4/CTyY+fA0Id9yUnBxQ3EssGQN5WA5FZeTGDf5arxJlFFX1/Vgss?= =?us-ascii?Q?ef2+k3SB07YBIkgs9YC9qTuURoqC55UNFWZbWXQGl2cEIGmzUkWmvpCRMBKN?= =?us-ascii?Q?4ypi0peWGUxDKgeBdFd7HJ7lmA92ddC8jTL8Bl0k9iejK/zwuAqllYDN1oW4?= =?us-ascii?Q?wv55tOYua69iJ9wsCjhlKMvGh8uPbdccpQKChfzMZfygpZvFqRYhXp5dzEXu?= =?us-ascii?Q?i1tYQemndEKVFqs3ymzFrQMlktr30BE7J559gnaXeyU0MKyz1R8v2e/DGnEh?= =?us-ascii?Q?psq2sKmM2aVmAl06DTv++bvLGikFBU9iY4He0iW0iS/0QSmrIu5jepC881jD?= =?us-ascii?Q?G6HeIAYS6cc5tCjkmiG6BS9WOrS0+Esvs19wDu7cBChhGIFOr+9MKtUzQKAe?= =?us-ascii?Q?x5KycW8IxgLUSLRm2nTnUmrojW+8h0gANfb3/REN1tULs20JZ3sp/1SfdTdO?= =?us-ascii?Q?paH2Yi4PKg6YrGfBRfI94k0jkKCjumRFo+09PV+SoJQJmknF6KEO97aPW9Sh?= =?us-ascii?Q?x8eubHy47S0J3Zvb5hUEIlXxvMgMceEOuIryMIRNbF95+jSeBuKM2ANB2y6e?= =?us-ascii?Q?xDpod5KeDRHyyt9cZCwXPivqNWpd5QR4p0mWTbU0cQ7CNMkp1TleGIzm5no6?= =?us-ascii?Q?5ul863Ma2jqXciJZPmJM8AkFN7VFf+LOH0kfeVqvNL0FtO2RbB7LQvoFhaQ/?= =?us-ascii?Q?5/ax1UVhLk+lDVzV7XscQPr6eDglmiBxPlasoLyNpS8igi7gQfYKREkJjVYA?= =?us-ascii?Q?MJbZFtFrKo8pKBpHssYUfiOPopQlUfp87WsS0EMOQw4DJNsHdNY0h3rppbZS?= =?us-ascii?Q?X78IyX71P0YXtiMB66+7oczLZoRCTmJYT+YQTwMB+Yrj7S+hjh32iv7nRuJU?= =?us-ascii?Q?n1WAJWGCS3alXNsBcT9o4Eyv5q08avS3JcAfwuqjXZyjo+90xuZA+C9OpnwS?= =?us-ascii?Q?1AMvaFq8+GXxZshIW6aAwnBSwOM3yvNGQS36mA1SRLkYvBYiDmJ6ml/ys8Tm?= =?us-ascii?Q?xe/KgJtGyCbKHKsJtLKAhIjjdb2LQltez4i/L9V00v1TZfukuov82EcSI6Y?= =?us-ascii?Q?=3D?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-64da6.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: da545404-774f-4858-589b-08db89f55793 X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2023 14:18:23.7873 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR09MB3907 Received-SPF: pass client-ip=40.92.50.56; envelope-from=arthur.miller@live.com; helo=EUR02-DB5-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -7.08 X-Spam-Score: -7.08 X-Migadu-Queue-Id: 89D7651A0C X-Migadu-Scanner: mx1.migadu.com X-TUID: 0xjSgUqGX3Us Ihor Radchenko writes: > Arthur Miller writes: > >> I want to auto insert a title from an HTML page as description for an org link in >> my notes. I stumbled upon some old message by Miro Bezjak on this list: >> >> https://lists.gnu.org/archive/html/emacs-orgmode/2012-09/msg01435.html >> >> I have seen the replies, but I am not sure how to use >> org-make-link-description-function > > Since that time, Org got a capability to set description function > per link type. Just use > > (org-link-set-parameters "http" :insert-description #'your-function) > (org-link-set-parameters "https" :insert-description #'your-function) Thanks, after some thinkering I got it: #+begin_src emacs-lisp (defun my-org-insert-link () "Insert org link where default description is set to html title." (interactive) (let* ((url (or (current-kill 0) (read-string "URL: ")))) (org-insert-link nil url))) (defun org-desc-from-clipboard (url _desc) "Insert an org link into current buffer from an URL in clipboard." (with-current-buffer (url-retrieve-synchronously url t) (goto-char (point-min)) (let ((title "\\(.*\\)\\(/>\\|\\)")) (if (re-search-forward title nil t) (string-trim (match-string-no-properties 1)) url)))) (org-link-set-parameters "http" :insert-description #'org-desc-from-clipboard) (org-link-set-parameters "https" :insert-description #'org-desc-from-clipboard) #+end_src And I can do it async too, *but*; this will affect all insertions of links, right? I am not sure if it is safe/possible always to access the internet or do it asynchronously, so I'll abandon the ship and revert to home-cooked one just for the precautios measures: #+begin_src emacs-lisp (defun org-link-from-clipboard () "Insert an org link into current buffer from an URL in clipboard." (interactive) (let ((marker (point-marker)) (url (or (current-kill 0) (read-string "URL: ")))) (url-retrieve url (lambda (_status title) (goto-char (point-min)) (when (re-search-forward title nil t) (setq title (string-trim (match-string-no-properties 1)))) (with-current-buffer (marker-buffer marker) (save-excursion (goto-char (marker-position marker)) (org-insert-link nil url (or title url))))) '("\\(.*\\)\\(/>\\|\\)") t t))) #end_src But it was a bit of learning, thanks for pointing me in the right direction.