-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] helper function to register minor-mode #40
Comments
Good idea! Do you want to create a pull request for this? |
Hi! I wonder if this a good solution, though. There is a better way to do this? Bye! |
I wonder if the restriction on real files is actually necessary. It might be useful to annotate, say, a In general, I think @pascalfleury's solution is more obvious and natural than hooking into At any rate, I would prefer to add the finished code to the README, as opposed to annotate.el itself, as it seems unintuitive to me to want to annotate every single buffer. Just out of curiosity, what is your reasoning for using annotate.el in every single buffer? |
On Wed, Sep 18, 2019 at 11:23:34PM -0700, Bastian Bechtold wrote:
Hello!
I wonder if the restriction on real files is actually necessary. It
might be useful to annotate, say, a `term` buffer, then integrate
the annotations and export the buffer.
Good point! :)
In general, I think @pascalfleury's solution is more obvious and
natural than hooking into `find-file-hook`. It should be possible to
put all the blacklist and is-it-a-file logic into the `lambda` in
@pascalfleury's code example. Or am I missing something, there?
i tried but i got some weird effects (duplicated annotation), i think
i am lost some piece of the puzzle here, likely because i have no
experience with elisp. More efforts needed here. :)
At any rate, I would prefer to add the finished code to the README,
as opposed to *annotate.el* itself, as it seems unintuitive to me to
want to annotate every single buffer. Just out of curiosity, what
is your reasoning for using annotate.el in every single buffer?
What i do is use the 'find-file-hook' to load annotate mode, then i
check if the major mode of the buffer of the just visited file is in
the blacklist, if not i run some code contained in a function that is
mentioned in the keyword `:after-hook` of `define-minor-mode
annotate-mode ...`, is this wrong?
Bye!
C.
|
That sounds like annotate-mode is somehow activated multiple times. But honestly, I have no idea. |
Hi! I'm using this hook myself to make sure annotate loads the overlays the least as possible: (defun my-annotate-mode-hook ()
(let ((file-name (buffer-file-name))
(annotation-files (mapcar #'car (annotate-load-annotation-data))))
(when (and file-name
(member file-name annotation-files))
(annotate-mode +1))))
(add-hook 'find-file-hook #'my-annotate-mode-hook) I notice that this speeds up loading a file quite a bit compared to unconditionally adding |
Hi! Thanks for reviving this old issue! 👍 The only change i would suggest would be to substitute Do you think there is a way to integrate your hook into the main code someway or, if not, adding it as a FAQ's answers in the README file? Would you like to file an PR about one of the two solutions? Bye and thanks for sharing your code! |
By default, annotate-mode is only a local minor-mode, so it has to be registered in all relevant modes.
Given its across the board usefulness, it would be nice to have a function that helps register it more broadly.
Making it a global minor-mode by registering it everywhere lead to issues though. This
will make it available everywhere. It does interfere with some modes that a) use many faces [magit, org-agenda-mode] and b) are not backed by an actual file [where I think it makes not much sense].
A helper function to register it in any mode backed by a file, or letting the user specify in which major-mode s/he does not want the annotate-mode would help setting it up faster.
The text was updated successfully, but these errors were encountered: