Conversation
b6bd14c to
0901cc0
Compare
Oh I wasn't aware that this syntax is supported. Is it documented? I don't think we should support it. |
0901cc0 to
cf0ce86
Compare
No, It looks like some kind of hack because tempo will eval the element if it is not recognized.
I agree. |
cf0ce86 to
ffa5c07
Compare
|
I've removed some functions and variables that are better have them in tempo.el instead of tempel-tempo.el. I also realized that tempo.el supports elements returned by functions: Should tempel support this or only suport them in Update: This is caused by Line 721 in 1432664 Update 2#: |
72b29a4 to
185cb9f
Compare
185cb9f to
8c9607e
Compare
Tempel reevaluates arbitrary forms from the modification hook. Maybe we could try to evaluate first and if the returned value is a listp then treat the return value as fields and expand? What do you think? Instead of
Yes.
I think we could generalize Tempel and support alternative matchers in addition to
See my comment #192 (comment). |
8c9607e to
87a174a
Compare
I like the idea. I've implemented something like this, (this duplicates code from Lines 395 to 399 in 87a174a
I agree.
Yes, In fact, this is what tempo.el does with Another alternative is to use looking-back: (looking-back
(regexp-opt
(mapcar (lambda (name) (symbol-name (car name)))
(tempel--templates)))
(line-beginning-position))But i'm not sure if this can work.
Fine, Then I will keep |
fbffa7a to
81387e7
Compare
Looks good. I pushed your commit with minor modification, see 46d4f54. Does this work well in your tests? |
a472412 to
1229b1c
Compare
Yes, it does with I found a little problem when expanding lisp code, since they can return string, this code will prompt again: However, this is a minor problem, since it can be solved: Also I wonder if there is the possibility of adding an option to disable the highlighting, since tempo users can probably find it annoying. |
I think one could write |
| (and (or arg tempel-tempo-insert-region) | ||
| (tempel--region))))) | ||
| (when tag (tempel-tempo-add-tag tag tag-name taglist)) | ||
| tag-name)) |
There was a problem hiding this comment.
I would like to add tempo-define-template to Tempel instead. Tempel already has tempel-key and I think tempel-define-template can supersede it. We can use cl-defun with keyword arguments. Then tempel-tempo-define-template would only be a thin wrapper.
There was a problem hiding this comment.
One problem is that the template management is a bit different in Tempel and Tempo. In Tempel everything is provided dynamically by the template sources, and I've designed Tempel to work well with completion-at-point/completing-read. In contrast, Tempo uses various association lists of template names and functions. We have to find ways to reconcile the two approaches.
There was a problem hiding this comment.
I would like to add
tempo-define-templateto Tempel instead. Tempel already hastempel-keyand I thinktempel-define-templatecan supersede it. We can usecl-defunwith keyword arguments. Thentempel-tempo-define-templatewould only be a thin wrapper.
I agree, but for global and local templates?
tempo-define-template also creates a command to insert the template (probably useful for auto-insert) and a variable, should this be included too?
There was a problem hiding this comment.
One problem is that the template management is a bit different in Tempel and Tempo. In Tempel everything is provided dynamically by the template sources, and I've designed Tempel to work well with completion-at-point/completing-read. In contrast, Tempo uses various association lists of template names and functions. We have to find ways to reconcile the two approaches.
I think we should move all the code from tempel-tempo.el to tempo.el instead.
So tempo users will actually be using Tempel in the background without compromising Tempel code, they can use their tempo commands and option with the same behavior, they even can use the Tempel commands, it should also work as demonstrated in my tests (although slightly different)
There was a problem hiding this comment.
I've added tempel-define-template function, currently it only works for global templates, since i think tempel-path-templates can work for local templates:
Here is a little comparation between tempel-define-template and tempo-define-template:
(tempel-define-template
:fnname "cmake-library"
:name "lib"
:elements
'((P "project: " proj 'noinsert)
"cmake_minimum_required(VERSION 3.11)" n n
"set(CMAKE_POSITION_INDEPENDENT_CODE ON)" n
"set(CMAKE_EXPORT_COMPILE_COMMANDS ON)" n n
"project(" (s proj) n
" VERSION 0.1.0" n
" LANGUAGES CXX" n
" DESCRIPTION \"\"" n
" HOMEPAGE_URL \"\"" n
")" n n
"include(CTest)" n
"include(FetchContent)" n n)
:doc "Insert a cmake library")
(tempo-define-template
"cmake-library" ; fnname
'((P "project: " proj 'noinsert) ; elements
"cmake_minimum_required(VERSION 3.11)" n n
"set(CMAKE_POSITION_INDEPENDENT_CODE ON)" n
"set(CMAKE_EXPORT_COMPILE_COMMANDS ON)" n n
"project(" (s proj) n
" VERSION 0.1.0" n
" LANGUAGES CXX" n
" DESCRIPTION \"\"" n
" HOMEPAGE_URL \"\"" n
")" n n
"include(CTest)" n
"include(FetchContent)" n n)
"lib" ; name to expand
"Insert a cmake library" ; doc
;; 'taglist (probably useless in `tempel-define-template')
)There was a problem hiding this comment.
I thought a while about this, and I am not anymore sure that we should add tempel-define-template. In Tempel we can easily define additional templates without the need of such a function, see
https://github.com/minad/tempel?tab=readme-ov-file#adding-templates. Modes can also take advantage of this and create their own template lists. Then the mode can add the list locally to tempel-template-sources.
There was a problem hiding this comment.
Fine, I've removed tempel-define-template.
c712df8 to
a7bdc71
Compare
|
Regarding force pushing - I suggest to avoid this. Then it will be easier to follow the progress, and I could also apply some improvements to the code. We can still cleanup everything in the end, and the tempel-tempo adaptor will rather go to Emacs anyway? |
a7bdc71 to
412d1f0
Compare
412d1f0 to
b65efe5
Compare
I'm sorry, i used the force-push to keep the commit history clearer.
Yes, although I already have tempo.el rewritten using all the code from I think if there are no more suggestions, this PR could be merged. I can announce this in the emacs-devel thread and see if there's anything else to add/change in tempel. |
Yes, sure. I know. Could you please push the compatibility code here again - the current state? I would like to add some improvements as well if you agree.
I mean this code. You can add your tempo.el here.
I thought we could try two approaches. Either replace tempo.el completely with the adapter, or provide an additional variant of tempo.el based on Tempel, which would be loaded if some customization is set. |
tempel.el
Outdated
| (`(s ,name) (tempel--field name)) | ||
| (`(l . ,lst) (dolist (e lst) (tempel--element region e))) | ||
| (`(P . ,lst) ; Only for tempo backward compatibility | ||
| (tempel--placeholder (nth 0 lst) (nth 1 lst) (nth 2 lst) :only-prompt)) |
There was a problem hiding this comment.
Regarding only-prompt - I am not sure if I had already commented on that. (The inline comment history seems also affected by force pushes). In Tempel every field is "interactive". In contrast, reading from the minibuffer affects the experience negatively since template expansion is paused until the result from the minibuffer has been read. Therefore I had not supported this feature in Tempel until now. read-string is only used if noinsert is specified, since then there is no other possibility to read the input.
There was a problem hiding this comment.
Regarding only-prompt - I am not sure if I had already commented on that. (The inline comment history seems also affected by force pushes).
Oh, i didn't know it, I'm sorry.
In Tempel every field is "interactive". In contrast, reading from the minibuffer affects the experience negatively since template expansion is paused until the result from the minibuffer has been read. Therefore I had not supported this feature in Tempel until now.
read-stringis only used ifnoinsertis specified, since then there is no other possibility to read the input.
Fine, i've removed this part.
Although this will break some tests in tempel-tempo-tests.el, I'll see how to fix this.
There was a problem hiding this comment.
We can maybe keep the prompt argument such that you can override it in tempo.el. However I would not change the behavior in Tempel itself. But then, if we use Tempel as backend anyway, then we can simply consistenly use Tempel behavior. This means simply removing support for tempo-interactive.
I've restored
Ok, i've added it.
Sounds good to me. |
|
You've added tempel-tempo.el and tempo.el here. How do they relate? Do you plan to move all code to tempo.el? The tempo.el still contains a lot of code which is obsolete, like |
|
[ I apologize for the delay, I've been very busy (and probably still will be) and haven't had the time to reply ]
I think only the useful and core tempo functions (not commands) should be moved to |
|
I've also been busy with some other things. My suggestion would be this:
;;; tempo.el --- -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(defcustom tempo-use-tempel t
"Use Tempel."
:type 'boolean)
;; ... shared definitions ...
(require (if tempo-use-tempel 'tempo-tempel 'tempo-obsolete))
(provide 'tempo.el)
;;; tempo.el ends here
This way we can remove unwanted features more freely from tempo-tempel. We would still be mostly compatible. We keep tempo-obsolete in case someone wants 100% backward compatibility. Furthermore we can compare the two tempo profiles side by side. All this should only involve copying definitions around, and use what you already have. What do you think? (Please preserve the commit history here, if you can.) |
|
Sorry for the delay, I've been very busy, but i think I'm back in action.
I like the idea, probably this or next week i will have this done. |
|
Sorry for the noise (and disappointment), but I'm not sure how to proceed with this, I have some ideas on how to finish it, but I still don't know which one to choose. Also, this feature was meant to allow to merge Tempel into core. Currently, I think Tempel is perfectly fine where it is (in NonGNU ELPA), so I'm not sure if you share this opinion. What I could do is add some modern Tempo features. For example, I think a What do you think? |
Yes, this was the idea. My comment shows a way to do this: #192 (comment) The idea was that Tempo/Tempel are prepared here in this PR, but just as a staging ground for us to discuss. It won't actually be merged here. Some changes to Tempel have already been merged which improved compatibility, and more could be needed.
As I see it, there are no "modern" Tempo features. When I wrote Tempel I extracted all relevant parts and modernized the package as a whole. Instead of |

Part of #188, emacs-devel thread and #191 discussions.
Continuation of #191.
I've tested the tempel compatibility in
org-tempo.eland it works (even for the tempel.el commands), however it fails because it quotes the elements:This can be fixed by removing these quotes, but it seems that tempo supports this type of syntax. I wonder if tempel should also support this syntax (and warn that this is deprecated).