Code Monkey home page Code Monkey logo

annotate.el's Introduction

Hi, I'm Bastian, dad, hobby photographer, software developer, and signal processing scientist in Germany.

Both photography and programming are about telling stories. Expressing a complex algorithm in simple terms, or stunning vista in a compelling picture. Finding order and simplicity in a chaotic scene or code base. Therein lies the challenge and joy of life.

annotate.el's People

Contributors

bastibe avatar cage2 avatar conao3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

annotate.el's Issues

React to window size changes

  • Too small a frame currently does not show any annotations (this probably depends on #20)
  • When the frame size changes, annotations should re-flow

incompatible with `visual-line-mode`

Hi @bastibe,

This package looks very promising, but it conflicts with visual-line-mode. The reason I think the annotation needs some space in several right columns.

Is there any better choice to adjust the place to other?

Autoloading custom variables acts as hardcoding

Hello again,

Similar to bastibe/org-journal#87 the following autoload cookies act as hardcoded variable values:

annotate.el/annotate.el

Lines 71 to 111 in f089237

;;;###autoload
(defcustom annotate-file "~/.annotations"
"File where annotations are stored."
:type 'file
:group 'annotate)
;;;###autoload
(defface annotate-highlight
'((t (:underline "coral")))
"Face for annotation highlights."
:group 'annotate)
;;;###autoload
(defface annotate-annotation
'((t (:background "coral" :foreground "black")))
"Face for annotations."
:group 'annotate)
;;;###autoload
(defcustom annotate-annotation-column 85
"Where annotations appear."
:type 'number
:group 'annotate)
;;;###autoload
(defcustom annotate-diff-export-context 2
"How many lines of context to include in diff export."
:type 'number
:group 'annotate)
;;;###autoload
(defcustom annotate-use-messages t
"Whether status messages may appear in the minibuffer."
:type 'boolean
:group 'annotate)
;;;###autoload
(defcustom annotate-integrate-marker " ANNOTATION: "
"Marker that is written before every integrated annotation."
:type 'string
:group 'annotate)

I see you use a lot of autoloading... you really only need to autoload functions that the user would call before loading your mode, so e.g. really only:

annotate.el/annotate.el

Lines 56 to 65 in f089237

;;;###autoload
(define-minor-mode annotate-mode
"Toggle Annotate mode."
:init-value nil
:lighter " Ann"
:keymap (make-sparse-keymap)
:group 'annotate
:after-hook (if annotate-mode
(annotate-initialize)
(annotate-shutdown)))

All other autoload cookie comments can safely be removed ๐Ÿ˜Ž

Annotations not displaying (wrong-type-argument overlayp nil)

I've tried annotate.el on two different builds of Emacs and each time I get the error message:

Fontifying block...(wrong-type-argument overlayp nil)

The two build I tried were:

  1. OS X Homebrew emacs-mac-port 24.5.1 (as described in https://github.com/syl20bnr/spacemacs#os-x)
  2. Emacs 24.5.1 built from source running on Ubuntu 14.04

In both cases I started from a clean Emacs start (emacs -Q), load-file annotations.el annotate-mode C-c C-a test RET. The message immediately appears and the symbol my cursor was at has an underline.

Annotations are being saved, just not displayed.

Any idea? Thanks!

Doesn't work well with visual-fill-column

I wanted to use visual-fill-column to soft-wrap my text at column 80, so the annotations would be put to the right as I'd like it to be. Unfortunately, this didn't work as expected:

image
image

It seems that the annotations are treated like regular text to be wrapped. Is there any way to get around this?

Issues with displaying annotations out of visible range

Hi !
I just installed this package from melpa, and it gets emacs into a strange state.

when I add an annotation, and the current buffer does not show enough columns (e.g. my view has 62 colums visible), then adding an annotation fails with this message (from Message buffer):
Error during redisplay: (jit-lock-function 3042) signaled (args-out-of-range "where it all started" 0 -22)

Note how 85-62 = 23, and we get -22 (I guess it's zero-based).

And the annotation does not show. If I resize then buffer to make space, it displays it, so it gets stored.

When annotations are added when there is enough space, and then the buffer is resized, the annotation flows fine. Just at creation time it gets confused.

Multiple definitions of individual annotations

I'm not sure what the workflow was to cause this but I have multiple copies of the exact same annotation in annotations file for the same file. For example:

("/scp:xyz-remhost:/users/mmauger/proj/abcdef/ghijklmnopqrstuvx.sql" (1430 1450 "Added criteria") (7866 7866 "xxxxx") (7866 7866 "xxxxx") (17916 17917 "Do we need to accommodate time portions") (17916 17917 "Do we need to accommodate time portions"))

(I cleaned up the previously reported Tramp text properties on the file name.)

Tag current release for inclusion in melpa stable

Hi Bastibe!

As about three months have passed without pull requests i was thinking that the current version (0.6.2) of the library could be tagged to be included in melpa stable, what do you think about that? Is is a good idea? Should we upgrade the release to a higher number (like 0.7.0)?

Bye!
C.

[Feature Request] helper function to register minor-mode

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

(define-globalized-minor-mode global-annotate-mode annotate-mode
  (lambda () (annotate-mode 1)))
(global-annotate-mode 1)  ;; will interfere in some modes

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.

Detect file changes and update annotations accordingly

Save a file hash next to the file name to detect file changes. Warn the user about file changes when annotations are loaded.

Possibly save each annotation's line to it so that it can be found if the text positions don't match any more.

Add functionality for deleting all annotations for a file

Currently, the annotate-file will just keep growing forever.

Maybe it would be useful to add a time stamp and a file hash to the entry in annotate-file, so that the user can make intelligent decisions about whether the annotations are still relevant.

Working with visual-line-mode

Hi, thanks for a wonderful mode!

Wanted to ask if annotate-mode is designed to work with visual-line-mode for example in org-mode buffer?

I have it set to 'margin, but the effect is new line, with text aligne to the left.

gnome-shell-screenshot-VWP0Q0

Next steps

Hi Bastian!

I am thinking about what else can be done with this package, proposed roadmap so far:

  • [merged] add the possibility to delete and modify an annotation from the summary window;

  • [merged] place the annotation on a new line if too long;

  • update software version to 0.5.0 ;

  • update the README (WIP, see: #55)

  • how?

    • extract NEWS and Changelog from README into separate files;
    • update screenshots;
    • add installation instructions;
    • document new features

Bye!
C.

[feature request] enable annotating Info manual

Dear the maintainers of the package of annotate.el:

Thanks for writing this package, I find it useful when reading
computer programs. It makes my ideas seamlessly intergrated with
the sources very well.

My initial idea was to use this package to annotate the Info
manual. I found that it is very enjoyable to read the Elisp
manual inside the Info mode, so I thougth it would be better if I
could annotate my thoughts directly into the Info manual.

I tweaked some of the functions before Sept. 24. I was able to
achieve the function. Please see the following GIFs. I did not
report to you because I thought my code was not robust.

  1. Able to write notes in Info mode:
    a
  2. Able to write notes in the sub-nodes:
    b
  3. After reopen Emacs, it can reload all the notes in the Info manual:
    c

There are many commits after Sept. 24 and after that my tweaks
were not compatable with your code.

I was wondering that if someone could make a decent pull request
to this package.

Followings are my tweaks, and I hope it can help someone
interested in making it.

Thanks for your effort. Really appreciate it.

(add-to-list 'load-path "~/.emacs.d/annotate.el")
(require 'annotate)
(setq annotate-file (expand-file-name "~/Dropbox/myNote/annotations"))


;; for info file

;;;###autoload
(define-minor-mode annotate-mode
  "Toggle Annotate mode."
  :init-value nil
  :lighter " Ann"
  :keymap (make-sparse-keymap)
  :group 'annotate
  :after-hook (if annotate-mode
                  (progn (annotate-initialize) (split-window-below) (delete-other-windows))
                (annotate-shutdown)))

(defun tweak-annotate-load-annotations ()
  "Load all annotations from disk."
  (interactive)
  (let ((annotations (cdr (assoc-string
                           (substring-no-properties (or Info-current-file ""))
                           (annotate-load-annotation-data))))
        (modified-p (buffer-modified-p)))
    ;; remove empty annotations created by earlier bug:
    (setq annotations (cl-remove-if (lambda (ann) (eq (nth 2 ann) nil))
                                    annotations))
    (message "annotate is %s" annotations)
    (when (and (eq nil annotations) annotate-use-messages)
      (message "No annotations found."))
    (when (not (eq nil annotations))
      (save-excursion
        (dolist (annotation annotations)
          (let ((start (nth 0 annotation))
                (end (nth 1 annotation))
                (text (nth 2 annotation)))
            (message "hi")
            (annotate-create-annotation start end text)))))
    (set-buffer-modified-p modified-p)
    (font-lock-fontify-buffer)
    (if annotate-use-messages
        (message "Annotations loaded."))))

(defun annotate-initialize ()
  "Load annotations and set up save and display hooks."
  (tweak-annotate-load-annotations)
  (add-hook 'after-save-hook 'annotate-save-annotations t t)
  (add-hook 'window-configuration-change-hook 'font-lock-fontify-buffer t t)
  (font-lock-add-keywords
   nil '((annotate--font-lock-matcher (2 (annotate--annotation-builder))
                                      (1 (annotate--change-guard))))))

(defun tweak-annotate-save-annotations ()
  "Save all annotations to disk."
  (interactive)
  (let ((file-annotations (annotate-describe-annotations))
        (all-annotations (annotate-load-annotation-data))
        (filename Info-current-file))
    (if (assoc-string filename all-annotations)
        (setcdr (assoc-string filename all-annotations)
                file-annotations)
      (setq all-annotations
            (push (cons filename file-annotations)
                  all-annotations)))
    ;; remove duplicate entries (a user reported seeing them)
    (dolist (entry all-annotations)
      (delete-dups entry))
    ;; skip files with no annotations
    (annotate-dump-annotation-data (cl-remove-if
                                    (lambda (entry)
                                      (eq nil (cdr entry)))
                                    all-annotations))
    (if annotate-use-messages
        (message "Annotations saved."))))

editing should not move annotations

When text is inserted or deleted before the annotation box, this should not move the annotation.

Similarly, deleting the last character of a line should not remove the annotation.

Org mode: Annotations lose their position when subtrees are moved

Hi, @bastibe !

It seems that moving subtrees in org mode (e.g. calling (org-move-subtree-up) or (org-move-subtree-down)) messes up the positions of annotations. Unfortunately, I was not able to figure out what causes the problem yet. I will be looking into this but just wanted to let you know. Maybe you already have an idea for solving this.

Just let me know if you need further information...

Greetings

Matthias

Zero length annotation targets are not visible

Type C-SPC C-c C-a and you will get an annotation with the same start and end point (i.e., a zero length range). The annotation text is visible on the right, but there is no identification of the annotation itself. Zero length ranges should be handled like a single character location so that they are visible.

cl package required at runtime

When byte-compiled the warning above is issued.

Use (eval-when-compile (require 'cl)) rather than just (require 'cl)

Also, use cl-remove-if rather than remove-if.

This will work with any version of Emacs that supports ELPA/MELPA packages.

The file names in the annotation file have text properties

some of the files I use are accessed via TRAMP. The file name in the annotations file includes text properties as well as the name string. The text properties ought to be stripped off when stored in the annotation file and any lookup comparison ought to only match the string portion and ignore properties.

Annotations should not move if text is inserted

Usually, the annotate--change-guard detects text entry and deletes the annotation accordingly.

However, this does not work if the annotation ends on a new line. In this case, the annotation is displayed on the new line, but the change guard is only invoked on the previous line. Maybe annotations should be displayed on the last non-empty line instead.

Key assignments

Emacs has rules for the assignment of keyboard sequences that clash with the assignments used in annotate.

Minor modes can define C-c <punct>, which may activate a keymap. So, C-c = C-a would execute annotate-annotate etc.

Minor modes may bind commands to key sequences consisting of C-c followed by a
punctuation character. However, sequences consisting of C-c followed by one of {}<>:;,
or a control character or digit, are reserved for major modes. Also, C-c letter is
reserved for users. See Key Binding Conventions.
-- Emacs Elisp Ref, 22.3.2 Keymaps and Minor Modes

See Emacs Ref, Keys assigned for existing key assignments

annotate-load-annotations: Wrong type argument: stringp, nil

hello,

I get this backtrace:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  substring-no-properties(nil)
  annotate-load-annotations()
  annotate-initialize()
  annotate-mode()
  my-prog-modes-hook()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook emacs-lisp-mode-hook lisp-interaction-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook emacs-lisp-mode-hook lisp-interaction-mode-hook))
  run-mode-hooks(lisp-interaction-mode-hook)
  lisp-interaction-mode()
  command-line()
  normal-top-level()

when I run emacs (with toggle-debug-on-error) on my .emacs config: https://github.com/velkyel/dotfiles/blob/master/.emacs

emacs version:
GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1911)) of 2016-09-17

Not strictly a code issue

Hi Bastian,

i know this is not exactly a code issue but issue is made by human being so...

Because i do not know a simple way to get in touch with you i am using this method.

My question is simple. Are you fine?

Bye!
C.

Make messages optional

Would you consider adding a debug option that enables/disables the messages for annotate.el? It would make the module be more transparent when enabled.

For instance, I prefer seeing the path to the file I just saved the buffer to on C-x C-s rather than "Annotations saved.".

Files with no annotations are listed in the annotations file

I have annotation-mode enabled in the prog-mode-hook. As I update packages, the code needs to be read in to be byte compiled and I end up with an entry in the annotations file with that name. If a file has no annotations it probably ought not appear in the annotations list.

Buffers marked as modified

Hello and thank you for the package. It's neat.

As soon as I add an annotation, the buffer is marked as modified. I wonder if there is a way to get around this. The actual buffer contents to be written to disk have not changed; and only the annotation db needs to be updated. Is there a way to inhibit the modified status?

Thank you.

Info is a dependency

The usage of Info-current-file means that I had to (require 'info) or encounter an unknown variable error. I would think this should just be added to the top of annotate.el.

Scrolling

Great package! I think I have this bug. When the annotation appears at the very top of the window (or just hidden above) and scroll-down-line, it doesn't move. Scrolling with the mouse makes my cursor go to the top of the buffer. For the mouse wheel I have customized (setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) but the scroll-down-line also appears with emacs -q. Can it be reproduced?

Rethinking multiline annotation

Hello!

There are currently issues with multi line annotations, for helping discussion i paste here the relevant comment in PR #58

#58 (comment)

Hi Bastian!

I was investigating the issue we got annotating the newline and i have met some bugs in the process! :)

Unfortunately i come to the conclusion that is not possible to annotate the newline itself because of the role if has in the annotation process, in fact, when annotated, it propagate the annotation overlay (the one with the underline property) to the prefix text we use to pad the annotation (the actual text of annotation, i mean). This is a problem not only when try to annotate the newline but, also, when the annotated text is a multi line one (using a region) and -of course- it include a newline char.

A picture, probably is going to explain better:

https://www.autistici.org/interzona/img/misc/annot-long-overlay-newline.png

I scratched my head about this problem, i think i could split the multi line annotation in multiple overlay that skips the newline character: there will be a lot of works to refactor all the functionality but i hope this is doable, at least; i can not see solution when the only character annotated is the newline.

I hope there is a proper solution, though. Like if was possible to delete the overlay on part of the text or just remove the underline property.

Bye!
C.

I have a local branch that try to address this issue and my limited testing seems to shows that works but, even if everything worked (and i doubt this was true) this is just a starting point, comments are welcome!
Bye!
C.

PS: I will post a PR with the mentioned branch in the next hours.

multiple annotations feature requests

@bastibe Thanks for helping me fix the last issue.

Here i would like to ask if you can add one new feature to your package:
As described in my situation, i am using visual-line-mode so always be one paragraph one logical line. In this situation, there will be some demands that annotate several parts of the paragraph, respectively. But since now, it looks like that only on annotation is supported in your package.

Of course, if multiple annotations can be implemented, various text properties should also be considered in my opinion, that is, underlining words and their annotation should have same text properties, but differ with others in same paragraph.

Thanks ahead of time. I will be really appreciate if you can make it possible. I can help you to test at anytime, just please give me a notice!.

nil annotations

Sometimes there is created an annotation in this format: (1234 5678 nil), with nil at the end instead of a string. This breaks the annotation-mode for files with such annotations. I'm not sure what is the cause but I think it's related to canceling the annotation prompt.

Prevent undo tree

Cannot undo with commit f089237 (and not tested previous commits...)

The undo-tree-undo shows:

user-error: No further undo information [36 times]

And M-x undo shows:

primitive-undo: Unrecognized entry in undo list undo-tree-canary [2 times]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.