Giter Club home page Giter Club logo

annotate.el's Introduction

Annotate.el

https://elpa.nongnu.org/nongnu/annotate.svg

http://melpa.org/packages/annotate-badge.svg

http://stable.melpa.org/packages/annotate-badge.svg

introduction

This package provides a minor mode annotate-mode, which can add annotations to arbitrary files without changing the files themselves. This is very useful for code reviews. When annotate-mode is active, C-c C-a will create, edit, or delete annotations. https://raw.githubusercontent.com/bastibe/annotate.el/master/example.png

Usage

Quick start

With an active region, C-c C-a creates a new annotation for that region. With no active region, C-c C-a will create an annotation for the word under point. If point is on an annotated region, C-c C-a will edit that annotation instead of creating a new one. Typing C-c C-d or clearing the annotation deletes them.

Use C-c ] to jump to the next annotation and C-c [ to jump to the previous annotation.

Metadata

The current database for annotations is contained in the file indicated by the variable annotate-file (~/.emacs.d/annotations by default) but each user can change this value in a dynamic way using the command annotate-switch-db. This command will take care to refresh/redraw all annotations in the buffers that uses annotate-mode.

The database holds the hash of each annotated file so it can print a warning if the file has been modified outside Emacs (for example).

Warning can be suppressed setting the variable annotate-warn-if-hash-mismatch to nil.

Please note that switching database, in this context, means rebinding the aforementioned variable (annotate-file). This means than no more than a single database can be active for each Emacs session.

If an empty annotation database (in memory) is saved the database file is deleted instead, if annotate-database-confirm-deletion is non nil (the default) a confirmation action is asked to the user before actually remove the file from the file system.

related customizable variable

  • annotate-file
  • annotate-warn-if-hash-mismatch
  • annotate-database-confirm-deletion

Non centralized database

To use multiple database in the same Emacs session annotate-file should be made buffer-local,

see:

this thread and, in particular this message.

Finally, if the customizable variable annotate-file-buffer-local is non-nil (default nil), for each annotated file an annotation database is saved under the same directory that contains the annotated file.

The name of the annotation database is built concatenating the name of the annotated file without the optional extension and the string value bound to the customizable variable annotate-buffer-local-database-extension (default: notes), example follows:

annotated fileannotations file
/home/user/foo.c/home/user/foo.notes

Important note: if /home/user/foo.notes exists, will be overwritten.

related customizable variable

  • annotate-file-buffer-local
  • annotate-buffer-local-database-extension

Uninstalling

Users of no-littering can take advantage of its packages generated files management.

keybindings

C-c C-a (function annotate-annotate)

Creates a new annotation for that region.

With no active region, C-c C-a will create an annotation for the word under point. If point is on an annotated region, C-c C-a will edit that annotation instead of creating a new one. Clearing the annotation deletes them.

If annotate-annotation-confirm-deletion is non nil (the default is nil) a confirmation action is asked, using y-or-n-p, to the user before actually remove the annotation.

If point is the newline character and the customizable variable annotate-endline-annotate-whole-line is not nil (default is non nil) the whole line is annotated (or the next if the line is empty).

If the line contains a single annotation that cover all the line, annotating the newline will ask to edit the annotation. If annotate-endline-annotate-whole-line is nil annotating a newline will signal an error.

With a numeric prefix the annotations will be displayed with the faces indicated in annotate-highlight-faces and annotate-annotation-text-faces, respectively. The numeric prefix is used as index in the lists bound to the aforementioned variables.

The first theme can be addressed by the prefix 1, the second by the prefix 2 and so on.

related customizable variable

  • annotate-annotation-column;
  • annotate-annotation-confirm-deletion;
  • annotate-annotation-max-size-not-place-new-line;
  • annotate-annotation-position-policy;
  • annotate-endline-annotate-whole-line;
  • annotate-highlight-faces;
  • annotate-annotation-text-faces.

C-c C-d

Delete an annotation under point, if such annotation exists.

If annotate-annotation-confirm-deletion is non nil (the default is nil) a confirmation action is asked, using y-or-n-p, to the user before actually remove the annotation.

related customizable variable

  • annotate-annotation-confirm-deletion.

C-c ] (function annotate-goto-next-annotation)

Jump to the next annotation.

C-c [ (function annotate-goto-previous-annotation)

Jump to the previous annotation.

C-c C-s (function annotate-show-annotation-summary)

Show summary window.

A window with a list of annotated files together with their annotations is shown. If annotate-summary-ask-query is non nil (default is t) then a prompt is shown where the user can insert a query to filter the annotation database, see “Query Language” below.

The summary window allow editing and removing of annotation using the provided buttons.

The annotation text can be pressed to and will open the annotated file, placing the cursor at the point where the corresponding annotated text appears.

related customizable variable

  • annotate-summary-ask-query.

C-c C-c (function annotate-change-annotation-colors)

Change the color of the annotation below point (both higlight and annotation text colors are changed).

These changes are kept after the buffer is killed.

C-c C-p (function annotate-change-annotation-text-position)

Change the policy positioning the annotation below point, a message with the new policy is printed.

These changes are kept after the buffer is killed.

Exporting

Annotations can be exported annotate-export-annotations as commented unified diffs, like this:

https://raw.githubusercontent.com/bastibe/annotate.el/master/diff-example.png

Alternatively, they can be integrated annotate-integrate-annotations as comments into the current buffer, like this:

https://raw.githubusercontent.com/bastibe/annotate.el/master/integrate-example.png

related customizable variable

  • annotate-integrate-marker
  • annotate-diff-export-options
  • annotate-integrate-highlight
  • annotate-fallback-comment

Importing

An annotation database file can be imported using the command annotate-import-annotations.

When importing, overlapping annotations will be merged in a single annotation with the new annotated text that maximizes the portion of text annotated, e.g.

The quick brown fox ← text
 ^^^^^^^^           ← first annotation
      ********      ← second annotation
 +++++++++++++      ← merged annotation

The text of the merged annotation is the concatenated text of the two annotations.

Note that importing a database will modify permanently the file bound to the variable annotate-file. If unsure of the results, backup that file before importing.

related customizable variable

  • annotate-database-confirm-import.

Alternative visualization of annotations

For typographically difficult scenarios (or just because you prefer it), such as variable-width fonts or overlay-heavy modes, the default visualization system that renders the annotation into the buffer could not properly works.

In this case the users can switch to a “pop-up” style annotation setting to a non-nil value the variable annotate-use-echo-area.

When such variable’s value is not null, moving the mouse pointer over the annotated text will temporary show the annotation.

The actual visuals of this “pop-up” can be different depending of your system’s setup (see this pull request for a couple of examples.

Moreover if annotate-use-echo-area and annotate-print-annotation-under-cursor value both non null, placing the cursor over an annotated text region will print the annotation’s text in the minibuffer prefixed by the value of customizable variable annotate-print-annotation-under-cursor-prefix, after a delay (in seconds) defined by the variable annotate-print-annotation-under-cursor-delay.

Another alternative way to show annotations is provided by the command: annotate-summary-of-file-from-current-pos.

Calling this command will show a summary window that prints all the annotations related to annotated text that appears (in the active buffer) beyond the current cursor position.

related customizable variable

  • annotate-use-echo-area
  • annotate-print-annotation-under-cursor
  • annotate-print-annotation-under-cursor-prefix
  • annotate-print-annotation-under-cursor-delay
  • annotate-summary-of-file-from-current-pos.

Other commands

annotate-switch-db

This command will ask the user for a new annotation database files, load it and refresh all the annotations contained in each buffer where annotate minor mode is active.

See the docstring for more information and this thread for a possible workflow where this command could be useful.

annotate-toggle-annotation-text

Shows or hides annotation’s text under cursor.

annotate-toggle-all-annotations-text

Shows or hides the annotation’s text in the whole buffer.

More documentation

Please check M-x customize-group RET annotate as there is extensive documentation for each customizable variable.

BUGS

Known bugs

  • Annotations in org-mode source blocks will be underlined, but the annotations don’t show up. This is likely a fundamental incompatibility with the way source blocks are highlighted and the way annotations are displayed.
  • Because of a limitation in the Emacs display routines scroll-down-line could get stuck on a annotated line. So no fix can be provided by the authors of annotate.el, a possible

workaround is to call the command with a numeric prefix equals to one plus the number of annotation text lines below the annotated text.

For example:

foo bar baz
annotation

needs a prefix of 2: C-u 2 M-x scroll-down-line

But note that:

foo bar baz   annotation

Needs no prefix.

  • Deleting the first character of an annotated text will remove the annotation (this turned out to be useful, though).

Report bugs

To report bugs please, point your browser to the issue tracker.

Query Language

The summary window can shows results filtered by criteria specified with a very simple query language, the basis syntax for that language is shown below:

[file-mask] [(and | or) [not] regex-note [(and | or) [not] regexp-note ...]]

where:

file-mask
is a regular expression that should match the path of file the annotation refers to;
and, or, not
you guess? Classics logical operators;
regex-note
the text of annotation must match this regular expression.

Examples

lisp$ and TODO

matches the text TODO in all lisp files

Parenthesis can be used for the expression related to the text of annotation, like this:

lisp$ and (TODO or important)

the same as above but checks also for string `important’

/home/foo/

matches all the annotation that refers to file in the directory /home/foo

/home/foo/ and not minor

matches all the annotation that refers to file in the directory /home/foo and that not contains the text minor.

.* and "not"

the quotation mark (“) can be used to escape strings.

As a shortcut, an empty query will match everything (just press return at prompt).

FAQ

Sometimes the package does not respect the customizable variable’s value of annotate-annotation-position-policy, is this a bug?

No it is not, when a line which is using a non default font is annotated the software force the :new-line policy, that is the annotation will be displayed on a new line regardless of the value of the variable mentioned in the question.

This is necessary to prevent the annotation to be pushed beyond the window limits if an huge font is used by the annotated text.

LICENSE

This package is released under the MIT license, see file LICENSE

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

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.

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.

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.

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

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.

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.

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.".

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]

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?

[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.

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.

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?

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.

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!.

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.

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.

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

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?

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

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

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!

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 😎

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.

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.

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.

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.)

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.

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.

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.

[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."))))

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

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.

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.