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

302
init.org
View file

@ -106,6 +106,21 @@ then load it.
** Utility Functions ** 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 ** Get latest version of a github released project
Many projects nowadays use github to release their software. However 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. This enables direnv globally.
* Writing * Writing and Planning
** Org Mode ** Org Mode
*** Mixed Pitch Support by Default in Org *** Mixed Pitch Support by Default in Org
@ -1202,30 +1217,184 @@ Here is a snapshot of the keybindings dd <2024-07-30 Tue>.
*** Org Jira Integration *** Org Jira Integration
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
;; configure org-jira ;; configure org-jira
(use-package org-jira (use-package org-jira
:ensure (:host github :repo "ptillemans/org-jira" :branch "pti_fix_getUsers") :ensure (:host github :repo "ptillemans/org-jira" :branch "pti_fix_getUsers")
:commands (org-jira-get-issues org-jira-get-projects) :commands (org-jira-get-issues org-jira-get-projects)
:config :config
(setq org-jira-users '(("Peter Tillemans". "557058:bdf83521-663b-4ae6-9b71-487bb98e2add"))) (setq org-jira-users '(("Peter Tillemans". "557058:bdf83521-663b-4ae6-9b71-487bb98e2add")))
(setq jiralib-agile-page-size 1000) (setq jiralib-agile-page-size 1000)
(setq org-jira-custom-jqls (setq org-jira-custom-jqls
'( '(
(:jql " assignee = currentUser() and (created > '2024-01-01' of updated > '2024-01-01) order by created DESC" (:jql " assignee = currentUser() and (created > '2024-01-01' of updated > '2024-01-01) order by created DESC"
:limit 100 :filename "this-year") :limit 100 :filename "this-year")
)) (:jql "project = TTRK and (resolution = Unresolved OR updated>=-15d) ORDER BY priority DESC"
(make-directory "~/.org-jira" 'parents) :limit 100 :filename "~/Projects/timetrak/jira")
(setq jiralib-url (auth-source-pass-get "url" "customer/jira")) ))
(setq org-jira-custom-jqls (make-directory "~/.org-jira" 'parents)
'((:jql " assignee = currentUser() and project = TTRK order by priority DESC " :limit 100 :filename "~/Projects/timetrak/jira") (setq jiralib-url (auth-source-pass-get "url" "customer/jira"))
(:jql " assignee = currentUser() and createdDate >= '2024-01-01' order by created DESC " :limit 100 :filename "this-years-work"))) (setq org-jira-custom-jqls
(jiralib-login '((:jql " assignee = currentUser() and project = TTRK order by priority DESC " :limit 100 :filename "~/Projects/timetrak/jira")
(auth-source-pass-get "user" "customer/jira") (:jql " assignee = currentUser() and createdDate >= '2024-01-01' order by created DESC " :limit 100 :filename "this-years-work")))
(auth-source-pass-get 'secret "customer/jira"))) (jiralib-login
(auth-source-pass-get "user" "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 #+END_SRC
#+RESULTS: #+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 ** 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-shutdown
(kbd "<leader>c q") 'eglot-reconnect (kbd "<leader>c q") 'eglot-reconnect
(kbd "<leader>c n") 'flymake-goto-next-error (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 ;; Shutdown server when last managed buffer is killed
(setq eglot-autoshutdown t) (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)) (if (not (file-exists-p lsp_dir))
(mkdir lsp_dir t))) (mkdir lsp_dir t)))
#+END_SRC #+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 ** Configure Selected Languages
*** Rust Support *** Rust Support
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -1579,14 +1780,12 @@ Configure Geiser and Scheme
(kbd "<leader>c f") #'terraform-format (kbd "<leader>c f") #'terraform-format
(kbd "<leader>c F") #'terraform-format-buffer (kbd "<leader>c F") #'terraform-format-buffer
(kbd "<leader>c n") 'flymake-goto-next-error (kbd "<leader>c n") 'flymake-goto-next-error
(kbd "<leader>c p") 'flymake-goto-prev-error) (kbd "<leader>c p") 'flymake-goto-prev-error
:hook (kbd "]d") #'flymake-goto-next-error
(terraform-mode . (lambda () (outline-minor-mode 1))) (kbd "[d") #'flymake-goto-prev-error))
:bind)
#+END_SRC #+END_SRC
#+RESULTS: Map the keymap consistently to the eglot mappings.
: pti-ide-config
** Debugger Support ** Debugger Support
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -1710,6 +1909,7 @@ Configure Geiser and Scheme
#+RESULTS: #+RESULTS:
** Copilot Support ** Copilot Support
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package copilot (use-package copilot
:ensure (:host github :repo "zerolfx/copilot.el" :ensure (:host github :repo "zerolfx/copilot.el"
@ -1733,42 +1933,20 @@ Configure Geiser and Scheme
*** TODO move scheme configuration to the scheme section *** TODO move scheme configuration to the scheme section
or leave it here but move it to config, whatever makes most sense at or leave it here but move it to config, whatever makes most sense at
the moment. the moment.
** Flymake Error Diagnostics
** Gitlab Support
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(evil-define-key 'normal #'eglot-mode-map (use-package gitlab-ci-mode
(kbd "]d") #'flymake-goto-next-error :ensure (:host gitlab.com :repo "ptillemans/gitlab-ci-mode" :branch "fixes_2024")
(kbd "[d") #'flymake-goto-prev-error :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 #+END_SRC
** Electric Return #+RESULTS:
#+BEGIN_SRC emacs-lisp : [nil 26292 38256 549743 nil elpaca-process-queues nil nil 11000 nil]
;; 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
* Communication and Interwebs * Communication and Interwebs
** ERC configuration ** ERC configuration