diff options
| author | Mountain Man <43313373+MountainMan1312@users.noreply.github.com> | 2023-06-24 14:55:21 -0400 |
|---|---|---|
| committer | Mountain Man <43313373+MountainMan1312@users.noreply.github.com> | 2023-06-24 14:55:21 -0400 |
| commit | 013dc8a9550c181a5cd23b9585cea08d01df2ebf (patch) | |
| tree | 075b232e8d1e8c9f87c0038eba645bd1afa90a3e | |
| parent | Fix format and keybind for inserting date/time (diff) | |
| download | mmosmacs-013dc8a9550c181a5cd23b9585cea08d01df2ebf.tar.gz mmosmacs-013dc8a9550c181a5cd23b9585cea08d01df2ebf.tar.bz2 mmosmacs-013dc8a9550c181a5cd23b9585cea08d01df2ebf.zip | |
Separate keybinds for insert active/inactive date/time
| -rw-r--r-- | init.el | 32 |
1 files changed, 25 insertions, 7 deletions
| @@ -1324,18 +1324,36 @@ | |||
| 1324 | ;; --------------------------------- | 1324 | ;; --------------------------------- |
| 1325 | ;; Insert date/time at POINT | 1325 | ;; Insert date/time at POINT |
| 1326 | ;; ------------------------- | 1326 | ;; ------------------------- |
| 1327 | ;; [YYYY-MM-DD HH:mm] | 1327 | ;; Keybinds to quickly insert |
| 1328 | ;; date/time at point in the correct | ||
| 1329 | ;; format. | ||
| 1328 | ;; --------------------------------- | 1330 | ;; --------------------------------- |
| 1329 | 1331 | ||
| 1330 | (defvar mm/date-time-format "[%Y-%m-%d %a %H:%M]" | 1332 | ;; Active timestamp |
| 1331 | "Format of the date to insert with `mm/insert-date-time' function. See help of `format-time-string' for alternative formats.") | 1333 | (defvar mm/date-time-format-active "<%Y-%m-%d %a %H:%M>" |
| 1334 | "Active date/time format for `mm/insert-date-time-active' function. | ||
| 1335 | See help of `format-time-string' for alternative formats.") | ||
| 1332 | 1336 | ||
| 1333 | (defun mm/insert-date-time () | 1337 | (defun mm/insert-date-time-active () |
| 1334 | "Insert the current date time in the format of `mm/date-time-format' at POINT." | 1338 | "Insert active timestamp at POINT in the format of `mm/date-time-format-active'." |
| 1335 | (interactive) | 1339 | (interactive) |
| 1336 | (insert (format-time-string mm/date-time-format (current-time)))) | 1340 | (insert (format-time-string mm/date-time-format-active (current-time)))) |
| 1341 | |||
| 1342 | (global-set-key (kbd "C-c i D") (lambda () (interactive) (mm/insert-date-time-active))) | ||
| 1343 | |||
| 1344 | ;; Inactive timestamp | ||
| 1345 | (defvar mm/date-time-format-inactive "[%Y-%m-%d %a %H:%M]" | ||
| 1346 | "Inactive timestamp format for `mm/insert-date-time-inactive' function. | ||
| 1347 | See help of `format-time-string' for alternative formats.") | ||
| 1348 | |||
| 1349 | (defun mm/insert-date-time-inactive () | ||
| 1350 | "Insert inactive timestamp at POINT in the format of `mm/date-time-format-inactive'." | ||
| 1351 | (interactive) | ||
| 1352 | (insert (format-time-string mm/date-time-format-inactive (current-time)))) | ||
| 1353 | |||
| 1354 | (global-set-key (kbd "C-c i d") (lambda () (interactive) (mm/insert-date-time-inactive))) | ||
| 1355 | |||
| 1337 | 1356 | ||
| 1338 | (global-set-key (kbd "C-c i d") (lambda () (interactive) (mm/insert-date-time))) | ||
| 1339 | 1357 | ||
| 1340 | 1358 | ||
| 1341 | ;; --------------------------------- | 1359 | ;; --------------------------------- |