Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert a picture in code comment via Emacs

An idea has just came to my mind. Is there any methods to insert a picture in code comment to help explain our code? After all, a picture is worth a thousand words.

Since I use Emacs, is there any implementations for Emacs so far?

like image 418
wilbeibi Avatar asked Apr 02 '13 08:04

wilbeibi


2 Answers

Take a look at iimage-mode: it is a standard solution to display an image in a text buffer.

For example, given the following file:

/* an image is worth a thousand words:
 * <path/to/image.png>
 */
int main (int argc, char **argv) {
  return 0;
}

then running M-xturn-on-iimage-mode should display image.png in place of its path.


However, I agree with @user4815162342's comment that you need to distribute images along with source files and to remember updating them when needed (it is sometimes hard to update code comments when they are text only; it will IMO be harder to update image comments)

like image 175
François Févotte Avatar answered Sep 21 '22 03:09

François Févotte


Are you talking about ASCII graphics or actual images?

For ASCII art, there's the M-x artist-mode that allows you to draw simple (or not very simple) images. Also, if you need to draw ASCII-based UML diagrams, CEDET can do it for you.

For inserting actual images, there's a bunch of functions like create-image and insert-image, so writing a minor mode for inserting images to comments should be straightforward. I'm not aware of any ready-made solutions, though.

like image 37
shakurov Avatar answered Sep 20 '22 03:09

shakurov