From 1d30d5c432e7675beb6c613d3faad4fa8977c517 Mon Sep 17 00:00:00 2001 From: Alexander Lay-Calvert Date: Fri, 23 Sep 2022 14:16:08 -0400 Subject: [PATCH 1/4] Implemented a shorttitle substitution for templates, when creating notes in subdirs the shorttitle only uses that last part of the filename, not the entire path --- lua/telekasten.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index c771583..005ec44 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -613,6 +613,11 @@ local function linesubst(line, title, dates, uuid) uuid = "" end + shorttitle = string.match(title, '^.+/(.+)$') + if shorttitle == nil then + shorttitle = title + end + local substs = { hdate = dates.hdate, week = dates.week, @@ -637,6 +642,7 @@ local function linesubst(line, title, dates, uuid) saturday = dates.saturday, title = title, + shorttitle = shorttitle, uuid = uuid, } for k, v in pairs(substs) do From 1769465a74d61517e355a0066e0d125087da192d Mon Sep 17 00:00:00 2001 From: Alexander Lay-Calvert Date: Fri, 23 Sep 2022 14:19:20 -0400 Subject: [PATCH 2/4] Updated readme with substitution option --- README.md | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index e0ad586..70ac135 100644 --- a/README.md +++ b/README.md @@ -112,32 +112,32 @@ of being able to edit it. -- [0. Install and setup](#0-install-and-setup) - - [0.0 Prerequisites](#00-prerequisites) - - [0.0.1 Telescope](#001-telescope) - - [0.0.2 calendar-vim Plugin (optional)](#002-calendar-vim-plugin-optional) - - [0.0.3 For pasting images: xclip (optional)](#003-for-pasting-images-xclip-optional) - - [0.0.4 For image previews: telescope-media-files.nvim (optional)](#004-for-image-previews-telescope-media-filesnvim-optional) - - [catimg](#catimg) - - [viu](#viu) - - [telescope-media-files.nvim](#telescope-media-filesnvim) - - [0.1 Install the plugin](#01-install-the-plugin) - - [0.1.0 Other useful plugins](#010-other-useful-plugins) - - [0.2 Configure telekasten.nvim](#02-configure-telekastennvim) - - [0.3 Configure your own colors](#03-configure-your-own-colors) -- [1. Get Help](#1-get-help) -- [2. Use it](#2-use-it) - - [2.0 Telekasten command](#20-telekasten-command) - - [2.1 Telekasten command palette](#21-telekasten-command-palette) - - [2.2 Telekasten lua functions](#22-telekasten-lua-functions) - - [2.3 Link notation](#23-link-notation) - - [2.4 Tag notation](#24-tag-notation) - - [2.5 Note templates](#25-note-templates) - - [2.5.1 Template files](#251-template-files) - - [2.6 Using the calendar](#26-using-the-calendar) - - [2.7 Using the telescope pickers](#27-using-the-telescope-pickers) -- [3. Bind it](#3-bind-it) -- [4. The hardcoded stuff](#4-the-hardcoded-stuff) +* [0. Install and setup](#0-install-and-setup) + * [0.0 Prerequisites](#00-prerequisites) + * [0.0.1 Telescope](#001-telescope) + * [0.0.2 calendar-vim Plugin (optional)](#002-calendar-vim-plugin-optional) + * [0.0.3 For pasting images: xclip (optional)](#003-for-pasting-images-xclip-optional) + * [0.0.4 For image previews: telescope-media-files.nvim (optional)](#004-for-image-previews-telescope-media-filesnvim-optional) + * [catimg](#catimg) + * [viu](#viu) + * [telescope-media-files.nvim](#telescope-media-filesnvim) + * [0.1 Install the plugin](#01-install-the-plugin) + * [0.1.0 Other useful plugins](#010-other-useful-plugins) + * [0.2 Configure telekasten.nvim](#02-configure-telekastennvim) + * [0.3 Configure your own colors](#03-configure-your-own-colors) +* [1. Get Help](#1-get-help) +* [2. Use it](#2-use-it) + * [2.0 Telekasten command](#20-telekasten-command) + * [2.1 Telekasten command palette](#21-telekasten-command-palette) + * [2.2 Telekasten lua functions](#22-telekasten-lua-functions) + * [2.3 Link notation](#23-link-notation) + * [2.4 Tag notation](#24-tag-notation) + * [2.5 Note templates](#25-note-templates) + * [2.5.1 Template files](#251-template-files) + * [2.6 Using the calendar](#26-using-the-calendar) + * [2.7 Using the telescope pickers](#27-using-the-telescope-pickers) +* [3. Bind it](#3-bind-it) +* [4. The hardcoded stuff](#4-the-hardcoded-stuff) @@ -823,6 +823,7 @@ Currently, the following substitutions will be made during new note creation: | specifier in template | expands to | example | | --- | --- | --- | | `{{title}}` | the title of the note | My new note | +| `{{shorttitle}}` | the short title of the note | dir/subdir/My Note -> My Note | | `{{uuid}}` | UUID for the note | 202201271129 | | `{{date}}` | date in iso format | 2021-11-21 | | `{{prevday}}` | previous day's date in iso format | 2021-11-20 | From b2e4c52b172d785c126e09a63603819f9c037297 Mon Sep 17 00:00:00 2001 From: Alexander Lay-Calvert Date: Fri, 23 Sep 2022 14:27:15 -0400 Subject: [PATCH 3/4] Styled --- lua/telekasten.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index 005ec44..7899894 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -613,7 +613,7 @@ local function linesubst(line, title, dates, uuid) uuid = "" end - shorttitle = string.match(title, '^.+/(.+)$') + local shorttitle = string.match(title, "^.+/(.+)$") if shorttitle == nil then shorttitle = title end From 2b74c26d18c45d337fd500f0f4cb0814cc322a87 Mon Sep 17 00:00:00 2001 From: Alexander Lay-Calvert Date: Fri, 23 Sep 2022 14:30:27 -0400 Subject: [PATCH 4/4] Updated helpfile --- doc/telekasten.txt | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/doc/telekasten.txt b/doc/telekasten.txt index 0b42a90..43038d6 100644 --- a/doc/telekasten.txt +++ b/doc/telekasten.txt @@ -847,27 +847,28 @@ The following substitutions will be made during new note creation: | specifier | | | | in template | expands to | example | +-----------------+-----------------------+-----------------------------+ -| `{{title}}` | the title of the note | My new note | -| `{{uuid}}` | UUID of the note | 202201271129 | -| `{{date}}` | date in iso format | 2021-11-21 | -| `{{prevday}}` | previous day, iso | 2021-11-20 | -| `{{nextday}}` | next day, iso | 2021-11-22 | -| `{{hdate}}` | date in long format | Sunday, November 21st, 2021 | -| `{{rfc3339}}` | date in RFC3339 format| 2021-11-21T14:30Z+01:00 | -| `{{week}}` | week of the year | 46 | -| `{{prevweek}}` | previous week | 45 | -| `{{nextweek}}` | next week | 47 | -| `{{isoweek}}` | week in iso format | 2021-46 | -| `{{isoprevweek}}` | last week, iso | 2021-45 | -| `{{isonextweek}}` | next week, iso | 2021-47 | -| `{{year}}` | year | 2021 | -| `{{monday}}` | Monday, iso | 2021-11-15 | -| `{{tuesday}}` | Tuesday, iso | 2021-11-16 | -| `{{wednesday}}` | Wednesday, iso | 2021-11-17 | -| `{{thursday}}` | Thursday, iso | 2021-11-18 | -| `{{friday}}` | Friday, iso | 2021-11-19 | -| `{{saturday}}` | Saturday, iso | 2021-11-20 | -| `{{sunday}}` | Sunday, iso (see note)| 2021-11-21 | +| `{{title}}` | the title of the note | My new note | +| `{{shorttitle}} | the short title of the note | dir/dir/My Note -> My Note | +| `{{uuid}}` | UUID of the note | 202201271129 | +| `{{date}}` | date in iso format | 2021-11-21 | +| `{{prevday}}` | previous day, iso | 2021-11-20 | +| `{{nextday}}` | next day, iso | 2021-11-22 | +| `{{hdate}}` | date in long format | Sunday, November 21st, 2021 | +| `{{rfc3339}}` | date in RFC3339 format | 2021-11-21T14:30Z+01:00 | +| `{{week}}` | week of the year | 46 | +| `{{prevweek}}` | previous week | 45 | +| `{{nextweek}}` | next week | 47 | +| `{{isoweek}}` | week in iso format | 2021-46 | +| `{{isoprevweek}}` | last week, iso | 2021-45 | +| `{{isonextweek}}` | next week, iso | 2021-47 | +| `{{year}}` | year | 2021 | +| `{{monday}}` | Monday, iso | 2021-11-15 | +| `{{tuesday}}` | Tuesday, iso | 2021-11-16 | +| `{{wednesday}}` | Wednesday, iso | 2021-11-17 | +| `{{thursday}}` | Thursday, iso | 2021-11-18 | +| `{{friday}}` | Friday, iso | 2021-11-19 | +| `{{saturday}}` | Saturday, iso | 2021-11-20 | +| `{{sunday}}` | Sunday, iso (see note)| 2021-11-21 | +-----------------+-----------------------+-----------------------------+ Note: Sunday is adjusted to match the user's `calendar_monday` preference.