From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org.el: Call EXT-enable for `org-modules' (was Re: [PATCH] org-ctags.el: Do not activate on load)
Date: Tue, 30 Apr 2024 18:20:42 +0700 [thread overview]
Message-ID: <v0qk6b$12m4$1@ciao.gmane.io> (raw)
In-Reply-To: <87a5lbyxqx.fsf@localhost>
[-- Attachment #1: Type: text/plain, Size: 532 bytes --]
On 30/04/2024 17:02, Ihor Radchenko wrote:
> Max Nikulin writes:
>
>> Isn't it better to modify buggy org-ctags than to add various kludges to
>> tests?
>
> Applied, onto main.
I was expecting that you would be against it since it is a breaking change.
See a follow-up to
Ihor Radchenko. Re: Autoloading side effects
(was: Re: [BUG] org-mouse is activated without explicit require)
Mon, 12 Dec 2022 10:25:16 +0000
<https://list.orgmode.org/871qp4j4vn.fsf@localhost>
However now I am in doubts why org-ctags is not a minor mode.
[-- Attachment #2: 0001-org.el-Call-EXT-enable-for-org-modules.patch --]
[-- Type: text/x-patch, Size: 4796 bytes --]
From 9cf1ebd0d8a0b1aa059f049aeb0c297b114aa4e2 Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Tue, 30 Apr 2024 18:05:11 +0700
Subject: [PATCH] org.el: Call EXT-enable for `org-modules'
* lisp/org.el (org-load-modules-maybe): Activate extensions that
implement EXT-enable functions.
* etc/ORG-NEWS:
* lisp/org-ctags.el: Update docs.
It should simplify configuration for `org-ctags' users after badb09d67.
The idea was discussed in
Ihor Radchenko. Re: Autoloading side effects
(was: Re: [BUG] org-mouse is activated without explicit require)
Mon, 12 Dec 2022 10:25:16 +0000
<https://list.orgmode.org/871qp4j4vn.fsf@localhost>
An alternative from the same thread is converting org modules
to minor modes.
---
etc/ORG-NEWS | 23 +++++++++++++++++++----
lisp/org-ctags.el | 5 ++++-
lisp/org.el | 11 +++++++++--
3 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 8dbc3292d..708d11f4f 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -651,10 +651,14 @@ just =id:= links.
*** ~org-ctags~ is not activated by default any more
-To follow Emacs [[info:elisp#Coding Conventions][coding conventions]] and to avoid confusion of users
+To follow Emacs [[info:elisp#Coding Conventions][coding conventions]]
+and to avoid confusion of users
who accidentally get ~org-ctags~ autoloaded due to help completion,
-the library does not modify ~org-open-link-functions~ during loading
-any more. Run ~org-ctags-enable~ to setup hooks and advices:
+the library does not modify ~org-open-link-functions~ any more
+when it is loaded using ~(require 'org-ctags)~ or a similar construct.
+To setup hooks and advices either
+[[*~feature-enable~ functions are called for extensions from ~org-modules~][customize ~org-modules~]]
+and add ~org-ctags~ or run ~org-ctags-enable~ explicitly:
#+begin_src emacs-lisp
(with-eval-after-load "org-ctags"
@@ -1473,10 +1477,21 @@ buffer it will be added. If not specified, new headings are created
at level 1 at the end of the accessible part of the buffer, as before.
** Miscellaneous
+*** ~feature-enable~ functions are called for extensions from ~org-modules~
+
+Accordingly to Emacs [[info:elisp#Coding Conventions][coding conventions]]
+loading a library must not modify behavior
+since it may be done for the sake of help or command completion.
+To make user configuration more convenient, when an extension ~EXT~ listed
+in ~org-modules~ implements ~EXT-enable~ function, it is executed
+during loading of Org mode or in response to customization of ~org-modules~.
+So instead of ~(require 'EXT)~ in your init file add ~EXT~ to ~org-modules~.
+See also
+[[*~org-ctags~ is not activated by default any more][~org-ctags~ is not activated by default any more]].
+
*** =org-crypt.el= now applies initial visibility settings to decrypted entries
Previously, all the text was unfolded unconditionally, including property drawers.
-
*** Blank lines after removed objects are now retained during export
When certain objects in Org document are to be excluded from export,
diff --git a/lisp/org-ctags.el b/lisp/org-ctags.el
index d3af103dd..9313c43cd 100644
--- a/lisp/org-ctags.el
+++ b/lisp/org-ctags.el
@@ -57,10 +57,13 @@ ;;; Commentary:
;; (add-hook 'org-mode-hook
;; (lambda ()
;; (define-key org-mode-map "\C-co" 'org-ctags-find-tag-interactive)))
+;;
+;; To activate the library, you either need to add it to `org-modules'
+;; or to call `org-ctags-enable' explicitly:
+;;
;; (with-eval-after-load "org-ctags"
;; (org-ctags-enable))
;;
-;; To activate the library, you need to call `org-ctags-enable' explicitly.
;; It used to be invoked during library loading, but it was against Emacs
;; policy and caused inconvenience of Org users who do not use `org-ctags'.
;;
diff --git a/lisp/org.el b/lisp/org.el
index 2d1a2055f..7030000ef 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -724,10 +724,17 @@ (defvar org-modules-loaded nil
;;;###autoload
(defun org-load-modules-maybe (&optional force)
- "Load all extensions listed in `org-modules'."
+ "Load all extensions listed in `org-modules'.
+If an extension defines EXT-enable function then invoke it
+to activate the module."
(when (or force (not org-modules-loaded))
(dolist (ext org-modules)
- (condition-case-unless-debug nil (require ext)
+ (condition-case-unless-debug nil
+ (let* ((feature (require ext))
+ (enable-function (intern (concat (symbol-name feature)
+ "-enable"))))
+ (when (fboundp enable-function)
+ (funcall enable-function)))
(error (message "Problems while trying to load feature `%s'" ext))))
(setq org-modules-loaded t)))
--
2.39.2
next prev parent reply other threads:[~2024-04-30 11:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-09 23:57 [PATCH] `org-ctags-create-tags` creates empty TAGS file [9.6.15 (release_9.6.15 @ /home/martin/Projects/emacs/lisp/org/)] Martin Marshall
2024-02-10 4:49 ` Is there something people use instead of org-ctags? (was: [PATCH] `org-ctags-create-tags` creates empty TAGS file) Martin Marshall
2024-02-10 14:29 ` Ihor Radchenko
2024-02-10 14:27 ` [PATCH] `org-ctags-create-tags` creates empty TAGS file [9.6.15 (release_9.6.15 @ /home/martin/Projects/emacs/lisp/org/)] Ihor Radchenko
2024-02-10 21:10 ` Morgan Willcock
2024-02-10 21:20 ` Ihor Radchenko
2024-03-19 10:21 ` Max Nikulin
2024-03-20 12:08 ` Ihor Radchenko
2024-04-28 7:37 ` [PATCH] org-ctags.el: Protect shell specials in directory name Max Nikulin
2024-04-28 12:53 ` Ihor Radchenko
2024-04-28 16:51 ` Max Nikulin
2024-04-28 16:55 ` Ihor Radchenko
2024-04-28 16:58 ` Max Nikulin
2024-04-28 17:02 ` Ihor Radchenko
2024-04-29 10:26 ` Max Nikulin
2024-04-29 13:12 ` Ihor Radchenko
2024-04-29 16:54 ` [PATCH] org-ctags.el: Do not activate on load Max Nikulin
2024-04-30 10:02 ` Ihor Radchenko
2024-04-30 11:20 ` Max Nikulin [this message]
2024-05-01 10:21 ` [PATCH] org.el: Call EXT-enable for `org-modules' (was Re: [PATCH] org-ctags.el: Do not activate on load) Ihor Radchenko
2024-05-01 11:38 ` Max Nikulin
2024-05-01 13:57 ` Ihor Radchenko
2024-04-30 12:59 ` [PATCH] org-ctags.el: Do not activate on load Ihor Radchenko
2024-04-30 13:37 ` Max Nikulin
2024-04-30 15:31 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='v0qk6b$12m4$1@ciao.gmane.io' \
--to=manikulin@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).