emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [POLL] Should Org tempo be enabled by default? (expand templates


From: Aaron Ecay
Subject: Re: [O] [POLL] Should Org tempo be enabled by default? (expand templates thru e.g. "<s[TAB]")
Date: Wed, 02 May 2018 18:12:16 +0100
User-agent: Notmuch/0.26 (https://notmuchmail.org) Emacs/27.0.50 (x86_64-pc-linux-gnu)

Hi Rasmus,

2018ko maiatzak 2an, Rasmus Pank Roulund-ek idatzi zuen:
>> Finally, irrespective of which options are chosen, I think that org-tempo
>> would be better implemented in terms of a minor mode.  This would allow
>> it to be autoloaded, turned on/off for different buffer(s) in an emacs
>> session, and avoid duplicating the logic for activating global minor
>> modes.  Patch attached.
> 
> I agree.

OK, thatʼs good to know.  Iʼve held off on any pushing of the patch to
master until everything is worked out.  In the meantime, Iʼve put it in
a branch “org-tempo”.

I also added a second commit to that branch which implements my vision
of the upgrade path (deprecation warnings, etc.)  For convenience, that
patch is also attached to this email.

One remaining decision to make is: what is the future of org-tempo?  I am
sympathetic to the idea that the best place for it eventually would be
org-contrib or GNU ELPA, and not org core.  If that is decided now, then
we can include that information in the upgrade message (i.e. that users
who opt in to org-tempo will eventually have to install it specifically).

-- 
Aaron Ecay
>From 414503d59b2129c24e95e1e57b54d5662a17308b Mon Sep 17 00:00:00 2001
From: Aaron Ecay <address@hidden>
Date: Wed, 2 May 2018 17:48:18 +0100
Subject: [PATCH 2/2] Add compatibility code to org-tempo

This will warn users of <X style templates and prompt them to update
their .emacs if they want to continue using the feature.
---
 lisp/org-tempo.el | 40 +++++++++++++++++++++++++++++++++++++++-
 lisp/org.el       |  6 ++++++
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/lisp/org-tempo.el b/lisp/org-tempo.el
index 2feed24dc..9923fe769 100644
--- a/lisp/org-tempo.el
+++ b/lisp/org-tempo.el
@@ -40,7 +40,6 @@
 
 (require 'tempo)
 (require 'cl-lib)
-(require 'org)
 
 (defvar org-structure-template-alist)
 
@@ -193,6 +192,45 @@ templates are defined."
 (define-global-minor-mode org-tempo-global-mode org-tempo-mode
   org-tempo-mode--activate-in-buffer)
 
+
+;;; Compatibility code
+
+;;; The code in this section can be removed in the next major release
+;;; after org-tempo was released (currently projected to land in Org
+;;; 9.2, therefore removal after Org 10).  At that time, the code
+;;; activating org-tempo-global-mode should also be removed from
+;;; org.el, and (require 'org) should be added to the top of this
+;;; file.
+
+(defvar org-tempo--user-activated nil
+  "This will be set to t when we detect that the user has
+activated org-tempo in their .emacs.")
+
+(advice-add 'org-tempo-global-mode :after
+           (lambda (&rest _)
+             (setq org-tempo--user-activated t)))
+
+;;; TODO: should we also try to detect the case when the user adds
+;;; org-tempo-mode to org-mode-hook?
+
+(advice-add 'org-tempo-complete-tag :after
+           (lambda (&rest _)
+             (unless org-tempo--user-activated
+               (org-display-warning
+                (substitute-command-keys "It looks like you have \
+expanded a <X style structure template.
+
+That feature will be removed from Org in the next major release.
+If you would like to continue using it, you should
+add `(org-tempo-global-mode 1)' to your emacs initialization
+file (which will also disable this warning message).
+\\<org-mode-map>
+Alternatively, you may wish to use the new template expansion
+facility `org-insert-structure-template', which is bound to
+\\[org-insert-structure-template] in org-mode buffers.")))))
+
+
+
 (provide 'org-tempo)
 
 ;;; org-tempo.el ends here
diff --git a/lisp/org.el b/lisp/org.el
index 0b8e62357..c67c8d2c5 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -23582,6 +23582,12 @@ when non-nil, is a regexp matching keywords names."
          (lambda () (add-hook 'change-major-mode-hook
                               'org-show-all 'append 'local)))
 
+;; For compatibility; remove in Org 10
+(require 'org-tempo)
+(defvar org-tempo--user-activated)
+(let (org-tempo--user-activated)
+  (org-tempo-global-mode 1))
+
 (provide 'org)
 
 (run-hooks 'org-load-hook)
-- 
2.17.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]