1
0
Fork 0

Compare commits

...

10 commits

Author SHA1 Message Date
bd24cb6def [oni-elfeed] Fix regular expression for security updates 2023-04-15 23:14:44 -07:00
e178ca2d41 [oni-elfeed] Remove some dead feeds 2023-04-15 23:14:10 -07:00
5836a55f4c [oni-eshell] Shorten directories and add P4 informatin in Eshell
This also happens to include changes to the font for Eshell as an experiment and
setting the page delimiter so page navigation commands work on prompts.
2023-04-15 23:10:50 -07:00
7e581611fb [oni-core] Add function to debug more hidden errors
https://gist.github.com/jdtsmith/1fbcacfe677d74bbe510aec80ac0050c
2023-04-15 20:45:15 -07:00
3c75681b25 [oni-core] Disable previews for ‘consult-buffer’ 2023-04-15 20:44:57 -07:00
348f71e570 [oni-org] Experiment with using more contexts to filter tasks
Instead of adding a lot of tags and adding a lot of agendas filtering on them
I'm experimenting with using org-edna to make certain contexts a dependency of a
task to filter them out of my todo list.

Current contexts I'm experimenting with are:

- ‘day-of-week?’ to filter out tasks that I can only do on certain days.

- ‘night-time?’ to filter out anything that I can't do in the evening. Usually
  having to do with contacting others.

- ‘business-hours?’ to filter out anything that is outside of a certain
  timezone's “business hours”, defined by me as anywhere between 9am and 6pm.
2023-04-11 20:23:23 -07:00
c76c236991 [oni-elisp] Fix keybindings for IELM
‘paredit-mode’ appears to have added keybindings for ‘C-j’ and ‘RET’ that
weren't there before (or did I enable ‘paredit-mode’ in IELM recently?) and that
interfere with executing code.

This way of removing the keybindings works in a buffer-local only way so that in
other buffers the ‘RET’ and ‘C-j’ keybindings remain untouched.
2023-04-11 20:20:57 -07:00
1de5e3892c [oni-org] Simplify org element property access 2023-04-11 20:20:28 -07:00
f460c3a19f [oni-elfeed] Fix tagger that removes duplicates of Planet Emacslife
First: the match needs to be any entry that does match the names of the people
whos blogs I already follow.

Second: The search regular expression can't contain spaces. It seems to be the
same as any search query. So when a regular expression contains a space it's
considered two different search terms. This doesn't work when we're searching
for one option with a space in it (“Irreal” or “Sacha Chua” or “Andrea”) since
the syntax for the regular expression gets all messed up. Quickest workaround is
to match any whitespace instead.
2023-04-11 20:09:32 -07:00
9c1ef54e74 [oni-elfeed] Add another feed 2023-04-11 20:06:00 -07:00
5 changed files with 168 additions and 50 deletions

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2023.0401.230128
;; Version: 2023.0415.204431
;; Package-Requires: (oni-data-dir oni-embrace oni-hydra expand-region multiple-cursors gcmh diminish ws-butler which-key insert-char-preview mixed-pitch ace-window vertico marginalia orderless consult embark docstr)
;; This program is free software; you can redistribute it and/or modify
@ -429,7 +429,9 @@ _s_: String list"
(with-eval-after-load 'consult
(with-eval-after-load 'related-files
(add-to-list 'consult-buffer-sources 'oni-core-related-places-source)))
(add-to-list 'consult-buffer-sources 'oni-core-related-places-source))
(consult-customize consult-buffer :preview-key nil))
;;; Embark
@ -450,6 +452,28 @@ _s_: String list"
(slot . 0)
(window-width . oni-core-fit-window-to-buffer)))
;;; Extra debugging
;;; From https://gist.github.com/jdtsmith/1fbcacfe677d74bbe510aec80ac0050c
(defun oni-core-reraise-error (func &rest args)
"Call function FUNC with ARGS and re-raise any error which occurs.
Useful for debugging post-command hooks and filter functions,
which normally have their errors suppressed."
(condition-case err
(apply func args)
((debug error) (signal (car err) (cdr err)))))
(defun toggle-debug-on-hidden-errors (func)
"Toggle hidden error debugging for function FUNC."
(interactive "a")
(cond
((advice-member-p #'oni-core-reraise-error func)
(advice-remove func #'oni-core-reraise-error)
(message "Debug on hidden errors disabled for %s" func))
(t
(advice-add func :around #'oni-core-reraise-error)
(message "Debug on hidden errors enabled for %s" func))))
;;; Native Compilation
(setq native-comp-async-report-warnings-errors 'silent)

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2023.0401.234314
;; Version: 2023.0412.115324
;; Package-Requires: (elfeed olivetti)
;; This program is free software; you can redistribute it and/or modify
@ -39,7 +39,6 @@
(setq elfeed-feeds
'("http://nullprogram.com/feed/"
("http://planet.emacsen.org/atom.xml" emacs)
("http://oremacs.com/atom.xml" emacs)
("http://emacshorrors.com/feed.atom" emacs)
("http://emacsredux.com/atom.xml" emacs)
@ -53,8 +52,6 @@
"https://news.ycombinator.com/rss"
("https://lwn.net/headlines/newrss" linux)
("https://serversforhackers.com/feed.xml" linux)
"http://julien.danjou.info/blog/index.xml"
"https://sites.google.com/site/darkwavestyle/SecretPage1/posts.xml"
("http://lispblog.xach.com/rss" lisp)
"http://esr.ibiblio.org/?feed=rss2"
"http://feeds.feedburner.com/GiantRobotsSmashingIntoOtherGiantRobots"
@ -83,7 +80,8 @@
"https://planet.emacslife.com/atom.xml"
"https://www.reddit.com/r/wallpapers/new.xml"
"https://picolisp-explored.com/rss.xml"
"https://onethingwell.org/rss"))
"https://onethingwell.org/rss"
"https://hackaday.com/tag/cyberdeck/feed/"))
(add-hook 'elfeed-new-entry-hook
(elfeed-make-tagger :before "2 weeks ago"
@ -93,7 +91,11 @@
(add-hook 'elfeed-new-entry-hook
(elfeed-make-tagger :feed-url (rx "lwn.net")
:entry-title (rx bos (or "[$]"
"Security updates for"))
(seq "Security"
whitespace
"updates"
whitespace
"for")))
:remove 'unread))
;;; Mark any post not containing my resolutions as read.
@ -105,13 +107,16 @@
;;; Mark any post from Planet Emacslife read if I also follow the originating
;;; blog. This way I won't have so many duplicates.
(add-hook 'elfeed-new-entry-hook
(elfeed-make-tagger :feed-url (rx "planet.emacslife.com")
:entry-title `(not ,(rx bos (or "Irreal"
"Sacha Chua"
"Andrea")
":"))
:remove 'unread))
(defvar oni-elfeed-duplicate-tagger
(elfeed-make-tagger :feed-url (rx "planet.emacslife.com")
:entry-title (rx bos (or "Irreal"
(seq "Sacha" whitespace "Chua")
"Andrea")
":")
:remove 'unread)
"Tagger for elfeed that marks certain posts as read for Emacslife.")
(add-hook 'elfeed-new-entry-hook oni-elfeed-duplicate-tagger)
(add-hook 'elfeed-show-mode-hook #'oni-elfeed-enable-olivetti-mode)

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2023.0314.001059
;; Version: 2023.0411.133217
;; Package-Requires: (oni-company oni-flycheck oni-paredit oni-yasnippet oni-hydra rainbow-delimiters nameless erefactor flycheck-relint handle elisp-format)
;; This program is free software; you can redistribute it and/or modify
@ -84,6 +84,16 @@
(:eval (buffer-name ielm-working-buffer))
mode-line-end-spaces)))
(defun oni-elisp-ielm-remove-paredit-newline-keys ()
"Disable C-j and RET keybindings from paredit-mode."
(let ((oldmap (map-elt minor-mode-map-alist 'paredit-mode))
(newmap (make-sparse-keymap)))
(set-keymap-parent newmap oldmap)
(define-key newmap (kbd "RET") nil)
(define-key newmap (kbd "C-j") nil)
(make-local-variable 'minor-mode-overriding-map-alist)
(push `(paredit-mode . ,newmap) minor-mode-overriding-map-alist)))
(defhydra oni-elisp-hydra (:color teal :hint nil)
"
^Eval^
@ -102,6 +112,7 @@ _eb_: Buffer
(add-hook 'emacs-lisp-mode-hook 'paredit-mode)
(add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode)
(add-hook 'ielm-mode-hook #'oni-elisp-ielm-remove-paredit-newline-keys)
(add-hook 'ielm-mode-hook #'oni-elisp-setup-ielm-mode-line)
(add-hook 'ielm-mode-hook 'company-mode)
(add-hook 'ielm-mode-hook 'paredit-mode)

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2022.1127.221317
;; Version: 2023.0414.233822
;; Package-Requires: (eshell-fringe-status esh-autosuggest xterm-color eshell-syntax-highlighting)
;; This program is free software; you can redistribute it and/or modify
@ -81,34 +81,26 @@
(eshell/cd (file-name-directory (buffer-file-name (get-buffer buffer-name))))
(eshell-reset))
(defun oni-eshell-shorten-directories (path)
"Shorten PATH to a list of unique shortened directory names."
(let* ((directories (split-string path "/" t))
(new-path
(string-join
(mapcar (lambda (d)
(let ((name (substring d 0 1))
(length 1))
(while (cl-find-if (lambda (s) (and (not (string= s d))
(string-prefix-p name s)))
directories)
(setq name (substring d 0 (cl-incf length))))
name))
directories) "/")))
(if (string-prefix-p "~" new-path)
new-path
(concat "/" new-path))))
(defun oni-eshell-disable-beacon-on-scroll ()
"Disable beacon-blink-when-window-scrolls in the current buffer."
(setq-local beacon-blink-when-window-scrolls nil))
(defun oni-eshell-change-font ()
"Remap the default font to the one I use for terminals."
(face-remap-add-relative 'default :family "Classic Console Neue"))
(defun oni-eshell-set-page-delimiter ()
"Change the page delimiter so that it matches the prompt for easy navigation."
(setq-local page-delimiter eshell-prompt-regexp))
(add-hook 'eshell-before-prompt-hook #'oni-eshell--set-xterm-variables)
(add-hook 'eshell-first-time-mode-hook #'oni-eshell--expand-keymap)
(add-hook 'eshell-load-hook #'oni-eshell--disable-ansi-color-handling)
(add-hook 'eshell-load-hook #'oni-eshell--enable-truncating-buffers)
(add-hook 'eshell-load-hook #'oni-eshell--enable-xterm-filter)
(add-hook 'eshell-mode-hook #'oni-eshell-change-font)
(add-hook 'eshell-mode-hook #'oni-eshell-disable-beacon-on-scroll)
(add-hook 'eshell-mode-hook #'oni-eshell-set-page-delimiter)
(add-hook 'eshell-mode-hook 'esh-autosuggest-mode)
(add-hook 'eshell-mode-hook 'eshell-syntax-highlighting-mode)
(add-hook 'eshell-mode-hook 'goto-address-mode)
@ -126,5 +118,81 @@
(slot . 0)
(window-height . 0.33)))
;;; Eshell prompt
(defun oni-eshell-shortest-unique-directory (current-path directory)
"Find the shortest unique substring of DIRECTORY.
DIRECTORY should be a directory that exists within CURRENT-PATH."
(catch 'result
(dotimes (i (length directory))
(let* ((current-directory (substring directory 0 (1+ i)))
(dir-rx (rx string-start
(literal current-directory)
(zero-or-more any)))
(matches (directory-files current-path nil dir-rx)))
(when (= (length matches) 1)
(throw 'result current-directory))))))
(defun oni-eshell-shorten-directory (directory)
"Shorten DIRECTORY to the shortest unique names of each directory."
(let ((current-path "/")
(current-short-path "/")
(home (concat (getenv "HOME") "/"))
(components (string-split (expand-file-name directory) "/" t)))
(dolist (dir components current-short-path)
(let* ((shortened (propertize (oni-eshell-shortest-unique-directory current-path dir)
'help-echo dir))
(new-path (format "%s%s/" current-path dir))
(new-short-path (if (string= new-path home)
"~/"
(format "%s%s/" current-short-path shortened))))
(setq current-path new-path
current-short-path new-short-path)))))
(defun oni-eshell-show-perforce-info-p ()
"Predicate to indicate whether or not powershell info should be shown."
(locate-dominating-file "." ".p4config"))
(defun oni-eshell-perforce-workspace ()
"Function returning the current Perforce workspace."
(car (map-elt (mapcar (lambda (str) (split-string str ": "))
(split-string (shell-command-to-string "p4 info -s") "\n"))
"Client name")))
(defun oni-eshell-perforce-root ()
"Function returning the root directory of the current Perforce workspace."
(string-replace
"\\"
"/"
(car (map-elt (mapcar (lambda (str) (split-string str ": "))
(split-string (shell-command-to-string "p4 info") "\n"))
"Client root"))))
(defun oni-eshell-perforce-stream ()
"Function returning the current Perforce stream."
(string-trim-right (shell-command-to-string "p4 switch")))
(defun oni-eshell-prompt-function ()
"Construct a prompt string for Eshell."
(let* ((perforcep (oni-eshell-show-perforce-info-p))
(pwd (eshell/pwd))
(dir (if perforcep
(concat (propertize (oni-eshell-perforce-workspace)
'face '((foreground-color . "#ca3cad90828e")))
":"
(let ((relative-path (string-remove-prefix (oni-eshell-perforce-root) pwd)))
(if (string= relative-path "") "/" relative-path)))
(oni-eshell-shorten-directory pwd)))
(stream (if perforcep (concat " ("
(propertize (oni-eshell-perforce-stream)
'face '((foreground-color . "#90e4ca3c828e")))
")")
"")))
(concat dir
stream
(if (= (user-uid) 0) " # " " $ "))))
(setq eshell-prompt-function #'oni-eshell-prompt-function)
(provide 'oni-eshell)
;;; oni-eshell.el ends here

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2023.0409.214302
;; Version: 2023.0411.202312
;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-contrib org-bullets org-edna diminish all-the-icons olivetti form-feed org-pretty-table)
;; This program is free software; you can redistribute it and/or modify
@ -600,16 +600,7 @@ also move point to the start of the heading."
(setq org-agenda-dim-blocked-tasks 'invisible)
(setq org-agenda-custom-commands
`(("t" . "Things to do")
("tt" "Todo at this computer" tags-todo ,(format "@%s|@computer|@emacs/TODO" (system-name))
((org-overriding-columns-format "%TODO %46ITEM %1BLOCKED %Effort")))
("tf" "Fun things to do" tags-todo "+fun")
;; ("r" "Reading list" tags-todo "TODO=\"READ\"+SCHEDULED=\"\"-Effort=\"\""
;; ((org-overriding-columns-format "%8CATEGORY %ITEM %3EFFORT")
;; (org-agenda-sorting-strategy '(priority-down effort-up))
;; (org-agenda-prefix-format " (%3e) %i %-12:c")))
;; ("R" "Reading list (requires estimating)" tags-todo
;; "TODO=\"READ\"+Effort=\"\"")
`(("t" "Todo" tags-todo "TODO=\"TODO\"-CATEGORY=\"project\"+(SCHEDULED<\"<tomorrow>\"|TODO=\"TODO\"-CATEGORY=\"project\"+SCHEDULED=\"\")")
("r" . "Reading")
("rc" "Casual reading" tags-todo "TODO=\"READ\"+casual")
("rn" "Noteworthy reading" tags-todo "TODO=\"READ\"+note")
@ -776,6 +767,26 @@ After running it once remove it from `org-capture-after-finalize-hook'."
(org-goto-first-child)
(list (point-marker))))
(defun org-edna-condition/day-of-week? (neg weekday)
(let ((condition (not (= (string-to-number (format-time-string "%u")) weekday))))
(when (xor condition neg)
"Not the right day.")))
(defun org-edna-condition/night-time? (neg)
"A condition for org-edna see if it's what I consider nighttime."
(let* ((hour (nth 2 (decode-time)))
(condition (or (> hour 20)
(< hour 8))))
(when (xor condition neg)
"Too late!")))
(defun org-edna-condition/business-hours? (neg timezone)
"A condition for org-edna to see if it's during regular business hours."
(let* ((hour (nth 2 (decode-time nil timezone)))
(condition (> 9 hour 18)))
(when (xor condition neg)
(format "Outside of business hours in %s!" timezone))))
;;; Refile
(defun oni-org-refile-to-top ()
@ -1083,10 +1094,9 @@ placed above TARGET. Otherwise it will be placed below it."
(goto-char (point-min))
(org-forward-heading-same-level 1)
(let* ((element (org-element-at-point-no-context))
(element-data (when element (cadr element)))
(element-title (when element-data (map-elt element-data :raw-value)))
(contents-begin (when element-data (map-elt element-data :contents-begin)))
(contents-end (when element-data (map-elt element-data :contents-end))))
(element-title (org-element-property :raw-value element))
(contents-begin (org-element-property :contents-begin element))
(contents-end (org-element-property :contents-end element)))
(when contents-begin
(let ((text (buffer-substring-no-properties contents-begin contents-end)))
(delete-region contents-begin contents-end)