13

When I’m in the middle of something and get an idea, I want to note it down without interrupting what I’m doing.

Desired workflow: adding a note

  1. I press a key (or a key combo).
    (should work everywhere: while browsing, while writing, while watching a video, etc.)

  2. A note window opens.
    (just a single text field, no title/category/etc.)
    (it must be empty)
    (doesn’t have to be a GUI)

  3. I enter my note.

  4. I press, e.g. Enter to save the note.
    (the window must close automatically)

Browsing notes

  • Just a simple list/table of all saved notes.
    • Especially not just text files which I’d have to open separately to read their content.
  • Should display the date/time when a note was saved.
  • Should offer a quick way to delete notes.
  • No need for editing notes.

Formal requirements

A solution must be FLOSS and run natively on GNU/Linux.

  • 1
    Not necessarily a proper answer if it has to be on Linux, but, do you have a cell phone? There are many note taking applications available for any operating system. (For Android, I use Google Keep, which has a nice home screen widget) – Yos233 Mar 11 '14 at 19:16
6

Sounds like a job for Emacs!

Install Emacs through your distribution's package manager.

Emacs comes with Remember Mode, which does pretty much what you want. (Note that there's a lot of complication in the Emacs Wiki that you don't care about, because it's for older versions of Emacs. Remember Mode is bundled since Emacs 23.)

To start taking a note, run the following shell command:

emacsclient -a "" -e "(let ((pop-up-frame-alist \`((window-system . x) (display . \"$DISPLAY\") ,@pop-up-frame-alist))) (remember-other-frame))"

(Having just -e "(remember-other-frame)" doesn't work if Emacs isn't already displaying a window due to a bad interaction between server mode and frame creation.) You can add other frame parameters in that list, with the syntax (NAME . VALUE). For example, to set a smaller height:

emacsclient -a "" -e "(let ((pop-up-frame-alist \`((window-system . x) (display . \"$DISPLAY\") (height . 8) ,@pop-up-frame-alist))) (remember-other-frame))"

Bind that shell command to a key in your window manager or desktop environment; each has its own way of doing this, so I can't describe them all.

Emacs will start if it isn't already running, and a new Emacs window showing an empty file will pop up. When you've finished taking that note, press Ctrl+C twice. If you want to change that key binding, you can do it in your .emacs, for example to use Ctrl+Return, use this code:

(require 'remember)
(define-key remember-mode-map [C-return] 'remember-finalize)

If you want to save some text from another application, copy it to the clipboard and run this command (which you may want to bind to a key as well):

emacsclient -a "" -c -e "(remember-clipboard)"

With this command, you need to press Ctrl+C twice, then close the window.

The notes are saved in the file ~/.notes (each new note is appended to that file). A header containing ** followed by the current time is automatically added at the beginning of the note.

To browse the notes, just open ~/.notes in your favorite text editor (such as Emacs).

If you want to save the notes to a different file, add a line like this to your ~/.emacs:

(setq remember-data-file "/path/to/notes/file")

What Remember mode lacks out of the box is a really convenient way of deleting a single note. You can of course select the text and delete it. Here's a function to delete the current note, plus a bit of infrastructure to bind it to a key when browsing the notes file. Put this code in your ~/.emacs.

(defun remember-current-note-extent ()
  (save-match-data
    (save-excursion
      (end-of-line)
      (let ((beg (search-backward (concat "\n" remember-leader-text))))
        (forward-char)
        (cons beg
              (if (search-forward (concat "\n" remember-leader-text) nil t)
                  (- (point) 1 (length remember-leader-text))
                (point-max)))))))
(defun remember-mark-current-note ()
  (interactive "@")
  (let ((bounds (remember-current-note-extent)))
    (set-mark (car bounds))
    (goto-char (cdr bounds))))
(defun remember-delete-current-note ()
  (interactive "@*")
  (let ((bounds (remember-current-note-extent)))
    (delete-region (car bounds) (cdr bounds))))

(defvar remember-notes-mode-map
  (let ((map (make-sparse-keymap)))
    (define-key map "\C-c\C-d" 'remember-delete-current-note)
    map)
  "Keymap for Remember Notes mode.")

(define-derived-mode remember-notes-mode text-mode "Notes"
  "Major mode to browse Remember notes.

\\{remember-notes-mode-map}"
  (require 'remember))
(add-to-list 'auto-mode-alist '("/\\.notes\\'" . remember-notes-mode))
  • 3
    I can't believe I just upvoted this. Please don't tell the rest of my vim purist friends. – Caleb Mar 12 '14 at 9:42
  • Thanks Gilles, sounds good! However, I can’t get it to work yet. – unor Mar 15 '14 at 20:46
  • Thanks for your help, it works now. (Except for the variant with remember-clipboard, but I’m not sure if I need that, as it seems to work to paste clipboard content with C-y when opening a note.) – unor Mar 16 '14 at 3:12
  • 1
    @unor The same issue affects remember-clipboard, it doesn't know that it should copy from the X clipboard when invoked from emacsclient. I've edited my answer here to use the clumsy -c workaround. – Gilles Mar 16 '14 at 3:28
3

It sounds to me like Tomboy would definitely do the job. Excerpt from the website:

Tomboy is a desktop note-taking application for Linux, Unix, Windows, and Mac OS X. Simple and easy to use, but with potential to help you organize the ideas and information you deal with every day.

Notable Features

  • Highlighting text
  • Inline spelll checking
  • Auto-linking web & email addresses
  • Undo/redo
  • Font styling & sizing
  • Bulleted lists
  • Note synchronization across several computers

Emacs-style binding can be used, and it has several plugins. As for the list without need of opening the notes, all notes can be exported to an HTML page. This whole thing may however be too fancy for your needs.

  • Thanks, this seems to be a good solution. I can set a hotkey for "Create new note", and hitting the Escape key closes the note (gets saved automatically). – unor Feb 25 '15 at 6:51
2

KNotes could be a good choice. KDE.org has the following description:

KNotes is a program that lets you write the computer equivalent of sticky notes. The notes are saved automatically when you exit the program, and they display when you open the program.

Here is the guide, if you're interested in its detailed usage.

As far as the objective is concerned, KNotes is a part of KDE applications, and so, it is by-default a FLOSS software and would work on GNU/Linux as long as its dependencies are met.

Usage

Bind KNotes to a key in your desktop environment. Using shortcut-key has one drawback that the app has to be initialized the very first time, after which it would sit in the task bar of your desktop until you Quit it.

It can be called everywhere using a key-combo, when using terminal, watching movies, browsing StackExchange and so on.

The default note closing key is Esc.

What's more?

Click on its icon in task bar and it will show a list of notes taken with format "Date Time". Clicking Show All Notes shows all of them, each in a new window.

Talk about Delete, you can do so by right-clicking at a note's title bar and choosing Delete.

Also, if you happen to wonder where does it store the notes, then look at $HOME/.kde/share/apps/knotes/notes.ics.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.