Skip to content
visible but not affect the source code
Branch: master
Clone or download
blue0513 Merge pull request #22 from conao3/change-save-file-path
use `locate-user-emacs-file` to specify default save file
Latest commit 795ef52 May 20, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information. use `locate-user-emacs-file` to specify default save file May 19, 2019

Phantom Inline Comment

Add visible inline-comments, which do not swear the source code as phantom.

What's This

You can add inline-comments which can be visible but does not affect the source code, i.e. even if you write comments, no changes will be made in the source code.

This package is useful when leaving a little note on the source code for yourself.
For example, when you write codes totally from scratch or when you read complex codes.

Image from Gyazo


git clone and edit your init.el as below.

(require 'phantom-inline-comment)
(add-to-list 'load-path "YOUR PATH")


Add/Edit a phantom comment

  • M-x phantom-inline-comment

Add or Edit one phantom under a line of the cursor.
After edit-buffer popups, you can write it.
Then C-c C-c to apply changes and C-g to cancel.

Delete a specific phantom comment

  • M-x phantom-inline-comment-delete

Delete one phantom under a line of the cursor.

Delete All phantom comments

  • M-x phantom-inline-comment-delete-all

Delete all the phantoms.

Show All phantom comments

  • M-x phantom-inline-comment-show-all

Show all the phantoms.
Then select a file and RET to jump to the phantom comment.

Fold/Unfold All the phantom comments

  • M-x phantom-inline-comment-toggle-all

Fold or Unfold all the phantoms.

Current Limitations

Since this package uses overlay, the phantom inline comment is not persisted.
After you quit emacs, the phantom inline comment you created will disappear.

To solve this problem, see Experimental section below.

Experimental: Persistent Phantoms

It's only experimental functions and not recommended.

In init.el, you can add settings as bellow.

;; Save phantom-inline-comments when quit Emacs
(phantom-inline-comment-auto-save-mode t)

;; Restore phantom-inline-comments when open files
(add-hook 'SOME-MODE-hook 'phantom-inline-comment-auto-restore-mode)

It allows you to save all the comments into the data-file (default ~/.emacs.d/pahtnom-inline-comment or ~/.phantom-inline-comment if it exists), before you quit Emacs.
And when you open the file you added comments, automatically the data-file will be loaded and the comments will be added again.

You can’t perform that action at this time.