various tweaks

- move electric return to programming infra
- configure org-jira with patched version
- org agenda views from @daviwil's video
- utility function to reload dir local variables
- patched version of gitlab-ci mode
This commit is contained in:
Peter Tillemans 2024-08-09 10:32:41 +02:00
parent 9a54cc903e
commit bcbd883576

264
init.org
View file

@ -106,6 +106,21 @@ then load it.
** Utility Functions
*** Reload dir local variables
#+BEGIN_SRC emacs-lisp
(defun pti-reload-dir-locals-for-current-buffer ()
"reload dir locals for the current buffer"
(interactive)
(let ((enable-local-variables :all))
(hack-dir-local-variables-non-file-buffer)))
#+END_SRC
#+RESULTS:
: pti-reload-dir-locals-for-current-buffer
** Get latest version of a github released project
Many projects nowadays use github to release their software. However
@ -692,7 +707,7 @@ Emacs' direnv module gives first class support to Emacs projects so they use the
This enables direnv globally.
* Writing
* Writing and Planning
** Org Mode
*** Mixed Pitch Support by Default in Org
@ -1213,6 +1228,8 @@ Here is a snapshot of the keybindings dd <2024-07-30 Tue>.
'(
(:jql " assignee = currentUser() and (created > '2024-01-01' of updated > '2024-01-01) order by created DESC"
:limit 100 :filename "this-year")
(:jql "project = TTRK and (resolution = Unresolved OR updated>=-15d) ORDER BY priority DESC"
:limit 100 :filename "~/Projects/timetrak/jira")
))
(make-directory "~/.org-jira" 'parents)
(setq jiralib-url (auth-source-pass-get "url" "customer/jira"))
@ -1221,11 +1238,163 @@ Here is a snapshot of the keybindings dd <2024-07-30 Tue>.
(:jql " assignee = currentUser() and createdDate >= '2024-01-01' order by created DESC " :limit 100 :filename "this-years-work")))
(jiralib-login
(auth-source-pass-get "user" "customer/jira")
(auth-source-pass-get 'secret "customer/jira")))
(auth-source-pass-get 'secret "customer/jira"))
:bind (("C-c ig" . 'org-jira-get-issues)
("C-c ip" . 'org-jira-get-projects)
("C-c ij" . 'org-jira-get-issues-from-custom-jql)
("C-c cc" . 'org-jira-add-comment)))
#+END_SRC
#+RESULTS:
: [nil 26283 18515 471588 nil elpaca-process-queues nil nil 496000 nil]
: [nil 26292 53013 676464 nil elpaca-process-queues nil nil 459000 nil]
It is very useful to create for each active project a custom JQL to
make a snapshot of issues just for that project in the folder of the
project to keep everything in context.
**** Keybindings
| Key | Command |
|---------+------------------------------------------|
| C-c pg | org-jira-get-projects |
| C-c bg | org-jira-get-boards |
| C-c iv | org-jira-get-issues-by-board |
| C-c ib | org-jira-browse-issue |
| C-c ig | org-jira-get-issues |
| C-c ij | org-jira-get-issues-from-custom-jql |
| C-c ih | org-jira-get-issues-headonly |
| C-c if | org-jira-get-issues-from-filter-headonly |
| C-c iF | org-jira-get-issues-from-filter |
| C-c iu | org-jira-update-issue |
| C-c iw | org-jira-progress-issue |
| C-c in | org-jira-progress-issue-next |
| C-c ia | org-jira-assign-issue |
| C-c isr | org-jira-set-issue-reporter |
| C-c ir | org-jira-refresh-issue |
| C-c iR | org-jira-refresh-issues-in-buffer |
| C-c ic | org-jira-create-issue |
| C-c ik | org-jira-copy-current-issue-key |
| C-c sc | org-jira-create-subtask |
| C-c sg | org-jira-get-subtasks |
| C-c cc | org-jira-add-comment |
| C-c cu | org-jira-update-comment |
| C-c wu | org-jira-update-worklogs-from-org-clocks |
| C-c tj | org-jira-todo-to-jira |
| C-c if | org-jira-get-issues-by-fixversion |
**** TODO add focused project support
There should be some things we can do to better integrate this with
projects:
- update issues in background when opening the project.
- run custom JQL defined in the project iso globally.
*** Daviwil's Productivity Tools
@daviwil has a set of productivity tools which are very useful. I have
**** Find all tasks with a specific tag (or without)
#+BEGIN_SRC emacs-lisp :tangle no
(setq org-agenda-custom-commands
'(("p" "Planning" tags-todo "+@planning")))
#+END_SRC
#+RESULTS:
| p | Planning | tags-todo | +@planning |
We can remove tasks with a certain tag by adding `-@work` to the pattern.
**** Find all tasks with a specific tag (or without)
#+BEGIN_SRC emacs-lisp :tangle no
(setq org-agenda-custom-commands
'(("u" "Untagged Tasks" tags-todo "-{.*}")))
#+END_SRC
#+RESULTS:
| u | Untagged Tasks | tags-todo | -{.*} |
**** Combine multiple filters
We can add a list of queries
#+BEGIN_SRC emacs-lisp :tangle no
(setq org-agenda-custom-commands
'(("p" "Planning" ((tags-todo "+@planning")
(tags-todo "-{.*}")))))
#+END_SRC
#+RESULTS:
| p | Planning | ((tags-todo +@planning) (tags-todo -{.*})) |
**** We can add settings to each filter
#+BEGIN_SRC emacs-lisp :tangle no
(setq org-agenda-custom-commands
'(("p" "Planning" ((tags-todo "+@planning"
((org-agenda-overriding-header "Planning Tasks")))
(tags-todo "-{.*}"
((org-agenda-overriding-header "Untagged Tasks")))))))
#+END_SRC
#+RESULTS:
| p | Planning | ((tags-todo +@planning ((org-agenda-overriding-header Planning Tasks))) (tags-todo -{.*} ((org-agenda-overriding-header Untagged Tasks)))) |
**** Add support for an input file
#+BEGIN_SRC emacs-lisp
(setq org-agenda-custom-commands
'(("i" "Inbox" ((todo ".*"
((org-agenda-files '("~/Dropbox/org/inbox.org"))
(org-agenda-overriding-header "Unprocessed Inbox Items")))))))
#+END_SRC
#+RESULTS:
| i | Inbox | ((todo .* ((org-agenda-files '(~/Dropbox/org/inbox.org)) (org-agenda-overriding-header Unprocessed Inbox Items)))) |
**** Daily Agenda
#+BEGIN_SRC emacs-lisp
(setq org-agenda-custom-commands
'(("d" "Daily Agenda"
((agenda "" ((org-agenda-span 'day)
(org-deadline-warning-days 1)
(org-agenda-overriding-header "Today's Agenda")))
(tags-todo "+PRIORITY=\"A\""
((org-agenda-overriding-header "High-Priority Unfinished Tasks")
))))))
#+END_SRC
#+RESULTS:
| d | Daily Agenda | ((agenda ((org-agenda-span 'day) (org-deadline-warning-days 1) (org-agenda-overriding-header Today's Agenda))) (tags-todo +PRIORITY="A" ((org-agenda-overriding-header High-priority unfinished tasks)))) |
**** Weekly Review
#+BEGIN_SRC emacs-lisp
(setq org-log-done 'time) ; log the time when a task is completed
(setq org-agenda-start-with-log-mode t) ; show the log mode when starting the agenda
(setq org-agenda-custom-commands
'(("w" "Weekly Review"
((agenda "" ((org-agenda-overriding-header "Completed Tasks")
(org-agenda-skip-function (org-agenda-skip-entry-if 'nottodo 'done))
(org-agenda-span 'week)))
(agenda "" ((org-agenda-overriding-header "Unfinished Scheduled Tasks")
(org-agenda-skip-function (org-agenda-skip-entry-if 'todo 'done))
(org-agenda-span 'week)))
))))
#+END_SRC
#+RESULTS:
| w | Weekly Review | ((agenda ((org-agenda-overriding-header Completed Tasks) (org-agenda-skip-function (org-agenda-skip-entry-if 'nottodo 'done)) (org-agenda-span 'week))) (agenda ((org-agenda-overriding-header Unfinished Scheduled Tasks) (org-agenda-skip-function (org-agenda-skip-entry-if 'todo 'done)) (org-agenda-span 'week)))) |
** Denote
@ -1276,7 +1445,10 @@ Here is a snapshot of the keybindings dd <2024-07-30 Tue>.
(kbd "<leader>c Q") 'eglot-shutdown
(kbd "<leader>c q") 'eglot-reconnect
(kbd "<leader>c n") 'flymake-goto-next-error
(kbd "<leader>c p") 'flymake-goto-prev-error)
(kbd "<leader>c p") 'flymake-goto-prev-error
(kbd "]d") #'flymake-goto-next-error
(kbd "[d") #'flymake-goto-prev-error
)
;; Shutdown server when last managed buffer is killed
(setq eglot-autoshutdown t)
@ -1394,6 +1566,35 @@ see also [[https://www.masteringemacs.org/article/how-to-get-started-tree-sitter
(if (not (file-exists-p lsp_dir))
(mkdir lsp_dir t)))
#+END_SRC
*** Electric Return
#+BEGIN_SRC emacs-lisp
;; enable electric return to automatically indent code
(defvar electrify-return-match
"[\]}\)\"]"
"The text after the cursor to do an \"electric\" return.")
(defun electrify-return-if-match (arg)
"Insert a newline, and indent it when needed.
If the text after the cursor matches `electrify-return-match' then
open and indent an empty line between the cursor and the text. Move the
cursor to the new line.
With a prefix argument ARG, insert that many newlines"
(interactive "P")
(let ((case-fold-search nil))
(if (looking-at electrify-return-match)
(save-excursion (newline-and-indent)))
(newline arg)
(indent-according-to-mode)))
;; Using local-set-key in a mode-hook is a better idea.
;(global-set-key (kbd "RET") 'electrify-return-if-match)
#+END_SRC
**** TODO Evaluate if Electric Return is still useful
** Configure Selected Languages
*** Rust Support
#+BEGIN_SRC emacs-lisp
@ -1579,14 +1780,12 @@ Configure Geiser and Scheme
(kbd "<leader>c f") #'terraform-format
(kbd "<leader>c F") #'terraform-format-buffer
(kbd "<leader>c n") 'flymake-goto-next-error
(kbd "<leader>c p") 'flymake-goto-prev-error)
:hook
(terraform-mode . (lambda () (outline-minor-mode 1)))
:bind)
(kbd "<leader>c p") 'flymake-goto-prev-error
(kbd "]d") #'flymake-goto-next-error
(kbd "[d") #'flymake-goto-prev-error))
#+END_SRC
#+RESULTS:
: pti-ide-config
Map the keymap consistently to the eglot mappings.
** Debugger Support
#+BEGIN_SRC emacs-lisp
@ -1710,6 +1909,7 @@ Configure Geiser and Scheme
#+RESULTS:
** Copilot Support
#+BEGIN_SRC emacs-lisp
(use-package copilot
:ensure (:host github :repo "zerolfx/copilot.el"
@ -1733,42 +1933,20 @@ Configure Geiser and Scheme
*** TODO move scheme configuration to the scheme section
or leave it here but move it to config, whatever makes most sense at
the moment.
** Flymake Error Diagnostics
** Gitlab Support
#+BEGIN_SRC emacs-lisp
(evil-define-key 'normal #'eglot-mode-map
(kbd "]d") #'flymake-goto-next-error
(kbd "[d") #'flymake-goto-prev-error
)
(use-package gitlab-ci-mode
:ensure (:host gitlab.com :repo "ptillemans/gitlab-ci-mode" :branch "fixes_2024")
:mode "\\.gitlab-ci\\.yml\\'"
:custom
(gitlab-ci-url "https://gitlab.melexis.com")
(gitlab-ci-api-token (auth-source-pass-get 'secret "snamellit/gitlab/token")))
#+END_SRC
** Electric Return
#+BEGIN_SRC emacs-lisp
;; enable electric return to automatically indent code
(defvar electrify-return-match
"[\]}\)\"]"
"The text after the cursor to do an \"electric\" return.")
(defun electrify-return-if-match (arg)
"Insert a newline, and indent it when needed.
If the text after the cursor matches `electrify-return-match' then
open and indent an empty line between the cursor and the text. Move the
cursor to the new line.
With a prefix argument ARG, insert that many newlines"
(interactive "P")
(let ((case-fold-search nil))
(if (looking-at electrify-return-match)
(save-excursion (newline-and-indent)))
(newline arg)
(indent-according-to-mode)))
;; Using local-set-key in a mode-hook is a better idea.
;(global-set-key (kbd "RET") 'electrify-return-if-match)
#+END_SRC
*** TODO Evaluate if Electric Return is still useful
#+RESULTS:
: [nil 26292 38256 549743 nil elpaca-process-queues nil nil 11000 nil]
* Communication and Interwebs
** ERC configuration