From b1e707d5544da0811f602eed125d8d5e64accd65 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Fri, 11 Oct 2024 20:13:06 +1100 Subject: [emacs] Some changes from the past months * emacs/.emacs.d/init/ycp-complete.el: comment why corfu does not work well with gud * emacs/.emacs.d/init/ycp-editing.el: bind my-write-file to C-x C-w; change viper-syntax-preference to 'extended * emacs/.emacs.d/init/ycp-org.el: comment on tab-width * emacs/.emacs.d/lisp/my/my-buffer.el: add a function `my-save-text-and-switch-to-buffer' that Save TEXT to FILE-NAME and switch to the buffer * emacs/.emacs.d/lisp/my/my-editing.el: renamed a function; and override `viper-forward-word-kernel' and `viper-backward-word-kernel' (why?); add function `my-write-file', which is the same as `write-file', but keep the old buffer and remain there. * emacs/.emacs.d/lisp/my/my-mariadb.el: remove sleep in `my-gdb-maria-spider'; add a function to fetch source of a mariadb kb entry * emacs/.emacs.d/lisp/my/my-net.el: extract out local I/O and buffer logic from `my-fetch-url-save-and-switch' to `my-save-text-and-switch-to-buffer'. * emacs/.emacs.d/lisp/my/my-org-jira.el: fix formatting of `my-org-jira--render-issue', and add affected-versions, fix-versions and related-issues for rendering * emacs/.emacs.d/lisp/my/my-prog.el: ensure indent-tabs-mode is by default nil in prog-modes, to protect from c-style-alist overriding * mariadb-server/.dir-locals.el: Moved from sql/.dir-locals.el --- emacs/.emacs.d/lisp/my/my-org-jira.el | 163 +++++++++++++++++----------------- 1 file changed, 82 insertions(+), 81 deletions(-) (limited to 'emacs/.emacs.d/lisp/my/my-org-jira.el') diff --git a/emacs/.emacs.d/lisp/my/my-org-jira.el b/emacs/.emacs.d/lisp/my/my-org-jira.el index 7ff7738..8f716c3 100644 --- a/emacs/.emacs.d/lisp/my/my-org-jira.el +++ b/emacs/.emacs.d/lisp/my/my-org-jira.el @@ -34,91 +34,92 @@ "Render single ISSUE." ;; (org-jira-log "Rendering issue from issue list") ;; (org-jira-log (org-jira-sdk-dump Issue)) + ;; (print Issue) (with-slots (filename proj-key issue-id summary status priority headline id) Issue (let (p) (with-current-buffer (org-jira--get-project-buffer Issue) (org-jira-freeze-ui - (org-jira-maybe-activate-mode) - (org-jira--maybe-render-top-heading proj-key) - (setq p (org-find-entry-with-id issue-id)) - (save-restriction - (if (and p (>= p (point-min)) - (<= p (point-max))) - (progn - (goto-char p) - (forward-thing 'whitespace) - (org-jira-kill-line)) - (goto-char (point-max)) - (unless (looking-at "^") - (insert "\n")) - (insert "** ")) - (org-jira-insert - (concat (org-jira-get-org-keyword-from-status status) - " " - (org-jira-get-org-priority-cookie-from-issue priority) - issue-id " " headline)) - (save-excursion - (unless (search-forward "\n" (point-max) 1) - (insert "\n"))) - (org-narrow-to-subtree) - (save-excursion - (org-back-to-heading t) - (org-set-tags-to (replace-regexp-in-string "-" "_" issue-id))) - (mapc (lambda (entry) - (let ((val (slot-value Issue entry))) - (when (or (and val (not (string= val ""))) - (eq entry 'assignee)) ;; Always show assignee - (org-jira-entry-put (point) (symbol-name entry) val)))) - '(assignee filename reporter type type-id priority labels resolution status components created updated sprint)) - - (org-jira-entry-put (point) "ID" issue-id) - (org-jira-entry-put (point) "CUSTOM_ID" issue-id) - - ;; Insert the duedate as a deadline if it exists - (when org-jira-deadline-duedate-sync-p - (let ((duedate (oref Issue duedate))) - (when (> (length duedate) 0) - (org-deadline nil duedate)))) - - (mapc - (lambda (heading-entry) - (ensure-on-issue-id-with-filename issue-id filename - (let* ((entry-heading - (concat (symbol-name heading-entry) - (format ": [[%s][%s]]" - (concat jiralib-url "/browse/" issue-id) issue-id)))) - (setq p (org-find-exact-headline-in-buffer entry-heading)) - (if (and p (>= p (point-min)) - (<= p (point-max))) - (progn - (goto-char p) - (org-narrow-to-subtree) - (goto-char (point-min)) - (forward-line 1) - (delete-region (point) (point-max))) - (if (org-goto-first-child) - (org-insert-heading) - (goto-char (point-max)) - (org-insert-subheading t)) - (org-jira-insert entry-heading "\n")) - - ;; Insert 2 spaces of indentation so Jira markup won't cause org-markup - (org-jira-insert - (replace-regexp-in-string - "^" " " - (format "%s" (slot-value Issue heading-entry))))))) - '(description)) - - (when org-jira-download-comments - (org-jira-update-comments-for-issue Issue) - - ;; FIXME: Re-enable when attachments are not erroring. - ;;(org-jira-update-attachments-for-current-issue) - ) - - ;; only sync worklog clocks when the user sets it to be so. - (when org-jira-worklog-sync-p - (org-jira-update-worklogs-for-issue issue-id filename)))))))) + (org-jira-maybe-activate-mode) + (org-jira--maybe-render-top-heading proj-key) + (setq p (org-find-entry-with-id issue-id)) + (save-restriction + (if (and p (>= p (point-min)) + (<= p (point-max))) + (progn + (goto-char p) + (forward-thing 'whitespace) + (org-jira-kill-line)) + (goto-char (point-max)) + (unless (looking-at "^") + (insert "\n")) + (insert "** ")) + (org-jira-insert + (concat (org-jira-get-org-keyword-from-status status) + " " + (org-jira-get-org-priority-cookie-from-issue priority) + issue-id " " headline)) + (save-excursion + (unless (search-forward "\n" (point-max) 1) + (insert "\n"))) + (org-narrow-to-subtree) + (save-excursion + (org-back-to-heading t) + (org-set-tags-to (replace-regexp-in-string "-" "_" issue-id))) + (mapc (lambda (entry) + (let ((val (slot-value Issue entry))) + (when (or (and val (not (string= val ""))) + (eq entry 'assignee)) ;; Always show assignee + (org-jira-entry-put (point) (symbol-name entry) val)))) + '(assignee filename reporter type type-id priority affected-versions fix-versions labels resolution status components created updated sprint related-issues)) + + (org-jira-entry-put (point) "ID" issue-id) + (org-jira-entry-put (point) "CUSTOM_ID" issue-id) + + ;; Insert the duedate as a deadline if it exists + (when org-jira-deadline-duedate-sync-p + (let ((duedate (oref Issue duedate))) + (when (> (length duedate) 0) + (org-deadline nil duedate)))) + + (mapc + (lambda (heading-entry) + (ensure-on-issue-id-with-filename issue-id filename + (let* ((entry-heading + (concat (symbol-name heading-entry) + (format ": [[%s][%s]]" + (concat jiralib-url "/browse/" issue-id) issue-id)))) + (setq p (org-find-exact-headline-in-buffer entry-heading)) + (if (and p (>= p (point-min)) + (<= p (point-max))) + (progn + (goto-char p) + (org-narrow-to-subtree) + (goto-char (point-min)) + (forward-line 1) + (delete-region (point) (point-max))) + (if (org-goto-first-child) + (org-insert-heading) + (goto-char (point-max)) + (org-insert-subheading t)) + (org-jira-insert entry-heading "\n")) + + ;; Insert 2 spaces of indentation so Jira markup won't cause org-markup + (org-jira-insert + (replace-regexp-in-string + "^" " " + (format "%s" (slot-value Issue heading-entry))))))) + '(description)) + + (when org-jira-download-comments + (org-jira-update-comments-for-issue Issue) + + ;; FIXME: Re-enable when attachments are not erroring. + ;;(org-jira-update-attachments-for-current-issue) + ) + + ;; only sync worklog clocks when the user sets it to be so. + (when org-jira-worklog-sync-p + (org-jira-update-worklogs-for-issue issue-id filename)))))))) ;; Overload `org-jira-update-worklogs-from-org-clocks'. (defun my-org-jira-update-worklogs-from-org-clocks () -- cgit v1.2.3