Skip to content

Add tag and notebook renaming #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ geeknote command.

![move](screenshots/geeknote-move.gif)

#### Renaming

Both tags and notebooks can be renamed.

`geeknote-rename-tag`: Rename a tag.

`geeknote-rename-notebook`: Rename a notebook.

### Indexes

Geeknote's indexes still work in this package. For example, you can search for a note
Expand Down
40 changes: 37 additions & 3 deletions geeknote.el
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,42 @@ NOTEBOOK the title of the notebook where NOTE should be moved."
(shell-quote-argument note)
(shell-quote-argument notebook))))

;;;###autoload
(defun geeknote-rename-tag (tag newname)
"Rename a given TAG to NEWNAME.

TAG the tag to rename.
NEWNAME the new name of the tag."
(interactive "sTag: \nsRename tag %s to: ")
(message (format "Renaming tag %s to %s..." tag newname))
(async-shell-command
(format (concat geeknote-command " tag-edit --tagname %s --title %s")
(shell-quote-argument tag)
(shell-quote-argument newname))))

;;;###autoload
(defun geeknote-rename-notebook (notebook newname)
"Rename a given NOTEBOOK to NEWNAME.

NOTEBOOK the notebook to rename.
NEWNAME the new name of the notebook."
(interactive "sNotebook: \nsRename notebook %s to: ")
(message (format "Renaming notebook %s to %s..." notebook newname))
(async-shell-command
(format (concat geeknote-command " notebook-edit --notebook %s --title %s")
(shell-quote-argument notebook)
(shell-quote-argument newname))))

;;;###autoload
(defun geeknote-list-notebooks ()
"List available notebooks."
(interactive)
(message (format "Listing notebooks..."))
(async-shell-command
(format (concat geeknote-command " notebook-list"))))

(defun geeknote-parse-title (title)
"Rerieve the title from the provided string. Filters out @notebooks and #tags.
"Retrieve the title from the provided string. Filters out @notebooks and #tags.

TITLE is the input given when asked for a new note title."
(let ((wordlist (split-string title)))
Expand All @@ -142,7 +176,7 @@ TITLE is the input given when asked for a new note title."
" ")))

(defun geeknote-parse-notebook (title)
"Rerieve the @notebook from the provided string. Returns nil if none.
"Retrieve the @notebook from the provided string. Returns nil if none.

TITLE is the input given when asked for a new note title."
(let ((wordlist (split-string title)))
Expand All @@ -156,7 +190,7 @@ TITLE is the input given when asked for a new note title."
0)))

(defun geeknote-parse-tags (title)
"Rerieve the #tags from the provided string. Returns nil if none.
"Retrieve the #tags from the provided string. Returns nil if none.

TITLE is the input given when asked for a new note title."
(let ((wordlist (split-string title)))
Expand Down