From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id WNVcKuj+fWdAJgAAqHPOHw:P1 (envelope-from ) for ; Wed, 08 Jan 2025 04:28:24 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id WNVcKuj+fWdAJgAAqHPOHw (envelope-from ) for ; Wed, 08 Jan 2025 05:28:24 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hb5I6OT2; 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=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1736310504; 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=Q4yVrbXkF/IR7k7CRRygmOs5HqNq4AKR0cWjVAOsxxU=; b=jBz392CqxVbg41Kh5naWrPlOot6hqNHP4znQiaqQurqe64L//qsy0678vxBwHDtPVR+N1K +7n2vDhvtQUbEo8J4SmU29HbVmDKdU3qfr/e2HrqaQKyEwojCthkrXPHRor7Z+WECdG1fg /aXjHBpr3oHzl/EvpXAW+Y/d20rJ5AhMlVSjcPsNBlG8rhmu2N/4Xv8e7aByDe3xEe0NmY ejK8crCT5iGqlHRYTgtie4tQHRwA5imi1hQLIvadT/Qhn3bq0ROL0V9UVEWAWvwUeCVnYg fVf3jCZwFCGTCLBbhHp87jsEYmJMFgMGe7jrYaxo/PWPc/kzcvR1IxnWqIQgfw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hb5I6OT2; 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=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1736310504; a=rsa-sha256; cv=none; b=qtnsqfdkkxY5JWrYjVzjpWuaDCGmx28YPBma5fT5vZSEEGtVJ+Jv9oNN+L/LpLYHi631pA rDpqvvZErszrTOygEo2koDDMdlh79wNuY+fWpb6VlgXy8N6GAM6fwtj7fvaswj7NZqBJ9l BxbFSxB/1FcpuBW8scXogJHHQANnbPIYOapbT3MCK0iyGOeZZEY2BaSef39n1TCZzkm+OX 8eK5WERCIC6aSlHcBHrdrJT3939RquTx8GCOLtLlCh0oyZtSD6xmU54TU8C4dehFyl3MSi I75lQQzfrocqTOKwvaatktSJ94ZU1yohCN3Nv18VHPOToCNT3RkcbGDsHcS3eg== 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 81F583BF3 for ; Wed, 08 Jan 2025 05:28:23 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVNfF-0004ZX-0h; Tue, 07 Jan 2025 23:27:29 -0500 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 1tVNfD-0004ZB-9v for emacs-orgmode@gnu.org; Tue, 07 Jan 2025 23:27:27 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVNf9-0004HG-Ib for emacs-orgmode@gnu.org; Tue, 07 Jan 2025 23:27:26 -0500 Received: by mail-pl1-x641.google.com with SMTP id d9443c01a7336-2166022c5caso214576515ad.2 for ; Tue, 07 Jan 2025 20:27:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736310441; x=1736915241; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Q4yVrbXkF/IR7k7CRRygmOs5HqNq4AKR0cWjVAOsxxU=; b=hb5I6OT2qEKO3eOmVbiDigX+99XUgA5YV97erljQRJ9wsCuombSNpFZS26t0vliDWK mcHbxBFk0UtVsnCZ7uG8P1B4tmJA2GrJoJutZD7OHMjfsRZE4hCmIxOG0SUsVu+jh6sA q5FHgfnMQqqk4mZFO8B9HGh18s/1yEs8VGz5We3+pPQ1RULOYIuLT/vIWPcDOHK8zuhC In1qYGRZ+5YKNikR+OZA81FP/Ug7QjIAgU6EVFW8OrE/reGGUmfveCv6SltihvEf1CaM iu0Onrnkvw7E5YHCDdQkgN/bPCajqJzIs8VKWF6BK6H/qWZqbKT75DO5BXE8+MQniPcQ NE1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736310441; x=1736915241; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Q4yVrbXkF/IR7k7CRRygmOs5HqNq4AKR0cWjVAOsxxU=; b=LE+oU2Saa3iAYxv7tZo5uCrJquHcnSLO+NVmf28v6394AuN1oyTcEd3cUppMjv7GPN ljRbBWgxCPdwao/pRca6RSWv8NV2/nAnODZGahQDrsCyiEkPV85u+QdnIzkoxJb+uRCW o0X3DmsOjYrojjPSah4fopOLMO0IODzdGtpbiHY9IIB1pkKrYlMDSV/DGIC0GmINwA2V 70OTxDW+NMmlNQZuasJiKwsaKKkwECQKRlTOzK2k/vFxlDtTjuw3L/SpFFSDfknLwSDy nDP+VnvwtpBcE6TkifcTMXwSU9f4l2CH7OxJwMfrMTyqrkjM4UdaKh8ebXMdaExAhpvm xD3w== X-Gm-Message-State: AOJu0YwgiQ2T6ghdU/oa4c5jNJP6disTPsADAAG3npxuyQ1uBsmsPDnt ViWEplWk90KIa/RtaO0iM2N6ODQOk+uQvx6zjmTH1OZdPXjwjFQ+ X-Gm-Gg: ASbGnctPL8Ifp9elcZfQrQ0nFBt0kkdJc6fos1obZDX8AFDKSZW82IxfZjcY4U7M+dt Ghn9xweb/91gnZAWSmLAOTh6Tz3Y6lDF++ECjvjzfQoD2/8aWqcsapBmB22/iF6A4Bpq7DDHAsl Db1p6gKjiKPv3ZjFcsx9pM7ttoVZlwPIGTi+yUKq5JB5RDzosOSFdI4te5/ELBN90NMrm0KwOCU HI/r5JdsWAqmq55s8jQfNqEzoAlmnlKe0At3bXfoMf45YOXJn4c X-Google-Smtp-Source: AGHT+IHu6C2W+bpidXffQrfF8goNpajTp1sDUi9XLudr0bKfIvQSZhUu1JIQ0bNrLWjyz9xzhpvZDQ== X-Received: by 2002:a05:6a20:431e:b0:1e2:5c9:6791 with SMTP id adf61e73a8af0-1e88cfa6e2emr3054461637.15.1736310441450; Tue, 07 Jan 2025 20:27:21 -0800 (PST) Received: from localhost ([49.204.137.15]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-8427ab7830asm31493307a12.0.2025.01.07.20.27.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 20:27:20 -0800 (PST) From: Visuwesh To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] Turn org-mouse features into minor-modes In-Reply-To: <874j2p7crt.fsf@localhost> (Ihor Radchenko's message of "Fri, 27 Dec 2024 08:25:58 +0000") References: <87seqad1sl.fsf@gmail.com> <874j2p7crt.fsf@localhost> Date: Wed, 08 Jan 2025 09:57:17 +0530 Message-ID: <878qrmudzu.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=visuweshm@gmail.com; helo=mail-pl1-x641.google.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-Queue-Id: 81F583BF3 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -4.17 X-Spam-Score: -4.17 X-TUID: uG3I+wBs9DW1 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable [=E0=AE=B5=E0=AF=86=E0=AE=B3=E0=AF=8D=E0=AE=B3=E0=AE=BF =E0=AE=9F=E0=AE=BF= =E0=AE=9A=E0=AE=AE=E0=AF=8D=E0=AE=AA=E0=AE=B0=E0=AF=8D 27, 2024] Ihor Radch= enko wrote: > Visuwesh writes: > >> [ Resending it as it seems like it never reached the mailing list. ] >> >> To make loading org-mouse less annoying for all, I was thinking of >> introducing minor-modes like in the attached patch. If this approach is >> acceptable, I will get to calling out the change in NEWS and updating >> the manual if required. We could also add a `add-hook' call to turn on >> the minor-mode automatically to preserve the old behaviour if required. >> WDYT? > > Thanks! > Adding minor modes is indeed a good idea. > Although they should probably be globalized to keep things closer to the > existing behavior. > > We do not need to preserve the old behavior - side effects are to be > eradicated even if the cost is introducing a breaking change. > NEWS announcement is good enough. I've now attached a patch to this effect. I hope the NEWS entry is legible. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-org-mouse-Make-it-possible-to-turn-on-and-off-the-fe.patch >From 99b9d8aa0b5ad14a015fdf7f7bfdc22eb804dde9 Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Mon, 23 Dec 2024 12:41:13 +0530 Subject: [PATCH] org-mouse: Make it possible to turn on and off the feature Introduce new minor-modes `org-mouse-minor-mode' and `org-mouse-agenda-minor-mode' to make it easy to turn on/off the mouse support. * lisp/org-mouse.el (org-mode-hook, org-agenda-mode-hook): Remove the lambda which makes it unnecessarily difficult to reverse the effect of loading this file. (org-mouse--old-mouse-map): New variable to hold the original definition of org-mouse-map. (org-mouse-minor-mode-map, org-mouse-minor-mode) (org-mouse-agenda-minor-mode-map, org-mouse-agenda-minor-mode): Add new minor-modes to easily toggle the mouse features on and off per buffer. * etc/ORG-NEWS: Announce the breaking change. Link: https://list.orgmode.org/87seqad1sl.fsf@gmail.com --- etc/ORG-NEWS | 15 ++++++ lisp/org-mouse.el | 120 ++++++++++++++++++++++++++-------------------- 2 files changed, 83 insertions(+), 52 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index c9bb192de..99d5b6b58 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -18,6 +18,21 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. # require user action for most Org mode users. # Sorted from most important to least important. +*** ~org-mouse~ is no longer activated by default by anymore + +To follow Emacs [[info:elisp#Coding Conventions][coding conventions]] and to avoid confusion of users who +accidentally get ~org-mouse~ autoloaded due to help completion, the +library does not modify ~org-mode-map~ and other variables during +loading anymore. + +To enable the ~org-mouse~ features, the new minor-modes +~org-mouse-minor-mode~ and ~org-mouse-agenda-minor-mode~ should be +enabled. + +To turn on the features in all ~org-mode~ and ~org-agenda-mode~ +buffers, you can use the globalized versions +~global-org-mouse-minor-mode~ and ~global-org-mouse-agenda-minor-mode~. + *** You may need to update =org-protocol= bookmarklets for browsers In Firefox-133, and Firefox-128.5 ESR the previously suggested diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el index 928d18d66..33f253fc4 100644 --- a/lisp/org-mouse.el +++ b/lisp/org-mouse.el @@ -866,48 +866,59 @@ (defun org-mouse-down-mouse (event) ;; events to `mouse-drag-region'. (put 'org-mouse-down-mouse 'ignored-mouse-command t) -(add-hook 'org-mode-hook - (lambda () - (setq org-mouse-context-menu-function #'org-mouse-context-menu) - - (when (memq 'context-menu org-mouse-features) - (org-defkey org-mouse-map [mouse-3] nil) - (org-defkey org-mode-map [mouse-3] #'org-mouse-show-context-menu)) - (org-defkey org-mode-map [down-mouse-1] #'org-mouse-down-mouse) - (when (memq 'context-menu org-mouse-features) - (org-defkey org-mouse-map [C-drag-mouse-1] #'org-mouse-move-tree) - (org-defkey org-mouse-map [C-down-mouse-1] #'org-mouse-move-tree-start)) - (when (memq 'yank-link org-mouse-features) - (org-defkey org-mode-map [S-mouse-2] #'org-mouse-yank-link) - (org-defkey org-mode-map [drag-mouse-3] #'org-mouse-yank-link)) - (when (memq 'move-tree org-mouse-features) - (org-defkey org-mouse-map [drag-mouse-3] #'org-mouse-move-tree) - (org-defkey org-mouse-map [down-mouse-3] #'org-mouse-move-tree-start)) - - (when (memq 'activate-stars org-mouse-features) - (font-lock-add-keywords - nil +(defvar org-mouse-minor-mode-map + (let ((map (make-sparse-keymap))) + (org-defkey map [mouse-3] #'org-mouse-show-context-menu) + (org-defkey map [down-mouse-1] #'org-mouse-down-mouse) + map) + "Keymap for `org-mouse-minor-mode'.") + +(defvar-local org-mouse--old-mouse-map (copy-keymap org-mouse-map)) +(define-minor-mode org-mouse-minor-mode + "Minor mode to enable better mouse support in `org-mode'." + :global nil + (let ((fl-fun (if org-mouse-minor-mode + (lambda (mode kw) + (font-lock-add-keywords mode kw t)) + #'font-lock-remove-keywords))) + (setq org-mouse-context-menu-function + (and org-mouse-minor-mode #'org-mouse-context-menu)) + (when org-mouse-minor-mode + ;; Without `copy-keymap', later `org-defkey' calls modify the + ;; value of keymap `org-mouse--old-mouse-map' holds. + (setq org-mouse--old-mouse-map (copy-keymap org-mouse-map))) + (setq org-mouse-map (copy-keymap org-mouse--old-mouse-map)) + (org-defkey org-mouse-minor-mode-map [S-mouse-2] nil) + (org-defkey org-mouse-minor-mode-map [drag-mouse-3] nil) + (when org-mouse-minor-mode + (when (memq 'context-menu org-mouse-features) + (org-defkey org-mouse-map [mouse-3] nil) + (org-defkey org-mouse-map [C-drag-mouse-1] #'org-mouse-move-tree) + (org-defkey org-mouse-map [C-down-mouse-1] #'org-mouse-move-tree-start)) + (when (memq 'yank-link org-mouse-features) + (org-defkey org-mouse-minor-mode-map [S-mouse-2] #'org-mouse-yank-link) + (org-defkey org-mouse-minor-mode-map [drag-mouse-3] #'org-mouse-yank-link)) + (when (memq 'move-tree org-mouse-features) + (org-defkey org-mouse-map [drag-mouse-3] #'org-mouse-move-tree) + (org-defkey org-mouse-map [down-mouse-3] #'org-mouse-move-tree-start))) + (when (memq 'activate-stars org-mouse-features) + (funcall fl-fun nil `((,org-outline-regexp 0 `(face org-link mouse-face highlight keymap ,org-mouse-map) - 'prepend)) - t)) - - (when (memq 'activate-bullets org-mouse-features) - (font-lock-add-keywords - nil + 'prepend)))) + (when (memq 'activate-bullets org-mouse-features) + (funcall fl-fun nil `(("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +" (1 `(face org-link keymap ,org-mouse-map mouse-face highlight) - 'prepend))) - t)) - - (when (memq 'activate-checkboxes org-mouse-features) - (font-lock-add-keywords - nil + 'prepend))))) + (when (memq 'activate-checkboxes org-mouse-features) + (funcall fl-fun nil `(("^[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\)[ \t]+\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\(\\[[- X]\\]\\)" - (1 `(face nil keymap ,org-mouse-map mouse-face highlight) prepend))) - t)) - - (advice-add 'org-open-at-point :around #'org--mouse-open-at-point))) + (1 `(face nil keymap ,org-mouse-map mouse-face highlight) prepend))))) + (if org-mouse-minor-mode + (advice-add 'org-open-at-point :around #'org--mouse-open-at-point) + (advice-remove 'org-open-at-point #'org--mouse-open-at-point)) + (font-lock-flush))) (defun org--mouse-open-at-point (orig-fun &rest args) (let ((context (org-context))) @@ -923,7 +934,6 @@ (defun org-mouse-move-tree-start (_event) (interactive "e") (message "Same line: promote/demote, (***):move before, (text): make a child")) - (defun org-mouse-make-marker (position) (with-current-buffer (window-buffer (posn-window position)) (copy-marker (posn-point position)))) @@ -1095,20 +1105,26 @@ (defun org-mouse-get-gesture (event) (if (< (car startxy) (car endxy)) :right :left))) - ; (setq org-agenda-mode-hook nil) -(defvar org-agenda-mode-map) -(add-hook 'org-agenda-mode-hook - (lambda () - (setq org-mouse-context-menu-function #'org-mouse-agenda-context-menu) - (org-defkey org-agenda-mode-map [mouse-3] #'org-mouse-show-context-menu) - (org-defkey org-agenda-mode-map [down-mouse-3] #'org-mouse-move-tree-start) - (org-defkey org-agenda-mode-map [C-mouse-4] #'org-agenda-earlier) - (org-defkey org-agenda-mode-map [C-mouse-5] #'org-agenda-later) - (org-defkey org-agenda-mode-map [drag-mouse-3] - (lambda (event) (interactive "e") - (cl-case (org-mouse-get-gesture event) - (:left (org-agenda-earlier 1)) - (:right (org-agenda-later 1))))))) +(defvar org-mouse-agenda-minor-mode-map + (let ((map (make-sparse-keymap))) + (org-defkey map [mouse-3] #'org-mouse-show-context-menu) + (org-defkey map [down-mouse-3] #'org-mouse-move-tree-start) + (org-defkey map [C-mouse-4] #'org-agenda-earlier) + (org-defkey map [C-mouse-5] #'org-agenda-later) + (org-defkey map [drag-mouse-3] + (lambda (event) (interactive "e") + (cl-case (org-mouse-get-gesture event) + (:left (org-agenda-earlier 1)) + (:right (org-agenda-later 1))))) + map) + "Keymap for `org-mouse-agenda-minor-mode'.") + +(define-minor-mode org-mouse-agenda-minor-mode + "Minor mode to enable better mouse support in `org-agenda-mode'." + :global nil + (setq org-mouse-context-menu-function + (and org-mouse-agenda-minor-mode + #'org-mouse-agenda-context-menu))) (provide 'org-mouse) -- 2.45.2 --=-=-=--