init.lisp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. ;; this is the main configuration file for tinmop.
  2. ;; This file must be a valid common lisp program to allow the program
  3. ;; to even starts. This file is actual common lisp source code that is
  4. ;; loaded end executed by the main program; be careful, do not copy
  5. ;; and paste code from untrusted sources as this could results in a
  6. ;; *severe* security damage.
  7. ;; Anyway, even if you do not know lisp you should be able to change
  8. ;; keybindings with no difficult. Editing this file is the way to
  9. ;; accomplish this task.
  10. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  11. ;; This line on top of the file is mandatory if you want to write a
  12. ;; module (AKA plugin) for the program as the form below will provide
  13. ;; you with access to many program's machinery
  14. (in-package :modules)
  15. ;; of course you can define new functions. Also note that the function called at
  16. ;; the end of the each command:
  17. ;;
  18. ;; (define-key "command keybinding" function)
  19. ;; ^^^^^^^^
  20. ;;
  21. ;; can not be an anonymous function.
  22. (defun quit () ; define a custom function named 'quit' and no parameters.
  23. "Quit the program" ; This string after the function name and parameters is
  24. ; called 'docstring' and will be presented to the
  25. ; user as inline help
  26. (ui:clean-close-program))
  27. ;; this file can load others using the 'load-module' function the file
  28. ;; in looked up in the home (e.g. $HOME/.config/tinmop/) config
  29. ;; directory or in the system wide config directory
  30. (load-module "next-previous-open.lisp")
  31. ;; share a gemini page
  32. (load-module "share-gemini-link.lisp")
  33. ;; keybindings syntax:
  34. ;; a command is executed after a sequence of one or more keys. a key
  35. ;; can be composed by a single physical button pressed on the keyboard
  36. ;; or by a combination of a button pressed together.
  37. ;; Example of keys are:
  38. ;; "a" -> press the button on the keyboard with the symbol 'a' printed on top
  39. ;; "a b" -> press and release the button 'a' and then press the button 'b'
  40. ;; "f1 f2" -> press function key 1 and function key 2
  41. ;; sometimes a key is composed by two pressed buttons. For example to
  42. ;; input the character 'C' (i.e. capital 'c') usually you should use a
  43. ;; combination of SHIFT and C but there is more: a key can be composed
  44. ;; by two button pressed, the first called a "modifier" button.
  45. ;; The "modifier" button must be keep pressed
  46. ;; while the second button is hit for the key to be valid.
  47. ;; There are only two legal modifier buttons: the "Alt" button
  48. ;; (indicated with the letter "M") and the "Control" button (indicated
  49. ;; with "C").
  50. ;; So said some combined keys example are given:
  51. ;; "M-1" -> press "Alt" and, while pressed, press "1"
  52. ;; Note the dash between the symbols, the key below:
  53. ;; "M 1"
  54. ;; means: "Press the combination of button to print the capital button
  55. ;; 'M' and the button to print the character '1', so this is not
  56. ;; equivalent to "M-1".
  57. ;; With this information in mind we can decode more keys like the ones
  58. ;; given below:
  59. ;; "C-c x" -> Press control and keep pressed press 'c' then release
  60. ;; the two buttons and press 'x'.
  61. ;; "C-c c" -> Press control and keep pressed press 'c' then release
  62. ;; the two buttons and press 'c' again.
  63. ;; Caveat:
  64. ;; - The single letter after control modifier are case insensitive;
  65. ;; - the enter key must be specified by "C-J";
  66. ;; - "dc" is the key Delete;
  67. ;; To define a new key just use the 'define-key' form below:
  68. ;; (define key COMMAND FUNCTION)
  69. ;; Where COMMAND is a sequence of keys and FUNCTION is the name
  70. ;; (prefixed by: #') of the function to fire after command has been
  71. ;; completed
  72. ;; See the command below as examples.
  73. ;; key conflict
  74. ;; Sometime two commands key may conflict, for example:
  75. ;; (define "C-x a" #'foo)
  76. ;; (define "C-x a b" #'bar)
  77. ;; How the program could know which way choose when the button 'a' is
  78. ;; pressed? Should be executed the function 'foo' or should we go
  79. ;; beyond this function and wait for the button 'b' to be pressed?
  80. ;; The convention chosen is that will be executed the shorter path
  81. ;; that lead to a function so, in the case above, the function 'foo'
  82. ;; will be executed.
  83. ;; Note that the two command below are *not* in conflict:
  84. ;; (define "C-x a b c d" #'foo)
  85. ;; (define "C-x a e" #'bar)
  86. (defun gemini-search ()
  87. (gemini-viewer:request "gemini://geminispace.info/search"))
  88. ;; global keymap
  89. (define-key "q" #'quit) ; here we are calling the custom
  90. ; function defined above
  91. (define-key "C-a" #'show-about-window)
  92. (define-key "?" #'print-quick-help)
  93. (define-key "C-h h" #'print-quick-help)
  94. (define-key "C-h a" #'apropos-help)
  95. (define-key "!" #'gemini-search)
  96. (define-key ">" #'open-gemini-address)
  97. (define-key "M-c" #'open-chats-list-window)
  98. (define-key "M-g s o" #'gemini-open-gemlog-window)
  99. (define-key "M-g s r" #'gemlog-refresh-all)
  100. (define-key "M-right" #'pass-focus-on-right)
  101. (define-key "M-left" #'pass-focus-on-left)
  102. (define-key "M-down" #'pass-focus-on-bottom)
  103. (define-key "M-up" #'pass-focus-on-top)
  104. ;; focus
  105. (define-key "f1" #'focus-to-tags-window)
  106. (define-key "f2" #'focus-to-thread-window)
  107. (define-key "f3" #'focus-to-message-window)
  108. (define-key "f4" #'focus-to-conversations-window)
  109. ;; follow requests keymap
  110. (define-key "up" #'follow-request-go-up *follow-requests-keymap*)
  111. (define-key "down" #'follow-request-go-down *follow-requests-keymap*)
  112. (define-key "d" #'follow-request-delete *follow-requests-keymap*)
  113. (define-key "C-J" #'process-follow-requests *follow-requests-keymap*)
  114. (define-key "q" #'cancel-follow-requests *follow-requests-keymap*)
  115. ;; send message keymap
  116. (define-key "up" #'attach-go-up *send-message-keymap*)
  117. (define-key "down" #'attach-go-down *send-message-keymap*)
  118. (define-key "d" #'attach-delete *send-message-keymap*)
  119. (define-key "s" #'change-subject *send-message-keymap*)
  120. (define-key "m" #'change-mentions *send-message-keymap*)
  121. (define-key "q" #'cancel-send-message *send-message-keymap*)
  122. (define-key "v" #'change-visibility *send-message-keymap*)
  123. (define-key "e" #'edit-message-body *send-message-keymap*)
  124. (define-key "C-J" #'send-message *send-message-keymap*)
  125. ;; thread window keymap
  126. (define-key "up" #'thread-go-up *thread-keymap*)
  127. (define-key "down" #'thread-go-down *thread-keymap*)
  128. (define-key "C-J" #'thread-open-selected-message *thread-keymap*)
  129. (define-key "dc" #'thread-mark-delete-selected-message *thread-keymap*)
  130. (define-key "U" #'thread-mark-prevent-delete-selected-message *thread-keymap*)
  131. (define-key "g" #'thread-goto-message *thread-keymap*)
  132. (define-key "/ b" #'thread-search-next-message-body *thread-keymap*)
  133. (define-key "\\\\ b" #'thread-search-previous-message-body *thread-keymap*)
  134. (define-key "/ m" #'thread-search-next-message-meta *thread-keymap*)
  135. (define-key "\\\\ m" #'thread-search-previous-message-meta *thread-keymap*)
  136. (define-key "N" #'repeat-search *thread-keymap*)
  137. (define-key "n" #'thread-search-next-unread-message *thread-keymap*)
  138. (define-key "home" #'thread-goto-first-message *thread-keymap*)
  139. (define-key "end" #'thread-goto-last-message *thread-keymap*)
  140. (define-key "c" #'compose-message *thread-keymap*)
  141. (define-key "r" #'reply-message *thread-keymap*)
  142. (define-key "x" #'refresh-thread *thread-keymap*)
  143. (define-key "v" #'open-message-attach *thread-keymap*)
  144. (define-key "l" #'open-message-link *thread-keymap*)
  145. (define-key "P" #'poll-vote *thread-keymap*)
  146. (define-key "C-c u" #'update-conversations *thread-keymap*)
  147. (define-key "C-c o" #'open-conversation *thread-keymap*)
  148. (define-key "C-c c" #'change-conversation-name *thread-keymap*)
  149. (define-key "C-f c" #'change-folder *thread-keymap*)
  150. (define-key "C-t c" #'change-timeline *thread-keymap*)
  151. (define-key "C-t u" #'update-current-timeline *thread-keymap*)
  152. (define-key "C-t U" #'update-current-timeline-backwards *thread-keymap*)
  153. (define-key "C-t R" #'reset-timeline-pagination *thread-keymap*)
  154. (define-key "C-t h r" #'refresh-tags *thread-keymap*)
  155. (define-key "C-u i" #'ignore-user *thread-keymap*)
  156. (define-key "C-u x" #'unignore-user *thread-keymap*)
  157. (define-key "C-u f" #'follow-user *thread-keymap*)
  158. (define-key "C-u r f" #'start-follow-request-processing *thread-keymap*)
  159. (define-key "C-u r r" #'report-status *thread-keymap*)
  160. (define-key "C-u u" #'unfollow-user *thread-keymap*)
  161. (define-key "C-u c k i" #'crypto-import-key *thread-keymap*)
  162. (define-key "C-u c k s" #'crypto-export-key *thread-keymap*)
  163. (define-key "C-u c k g" #'crypto-generate-key *thread-keymap*)
  164. (define-key "C-X m t" #'move-message-tree *thread-keymap*)
  165. (define-key "C-X m f" #'favourite-selected-status *thread-keymap*)
  166. (define-key "C-X m r f" #'unfavourite-selected-status *thread-keymap*)
  167. (define-key "C-X m b" #'boost-selected-status *thread-keymap*)
  168. (define-key "C-X m r b" #'unboost-selected-status *thread-keymap*)
  169. (define-key "C-X m s" #'subscribe-to-hash *thread-keymap*)
  170. (define-key "C-X m u" #'unsubscribe-to-hash *thread-keymap*)
  171. (define-key "|" #'send-message-to-pipe *thread-keymap*)
  172. ;; message window keymap
  173. (define-key "up" #'message-scroll-up *message-keymap*)
  174. (define-key "down" #'message-scroll-down *message-keymap*)
  175. (define-key "C-J" #'message-scroll-down *message-keymap*)
  176. (define-key "home" #'message-scroll-begin *message-keymap*)
  177. (define-key "end" #'message-scroll-end *message-keymap*)
  178. (define-key "/" #'message-search-regex *message-keymap*)
  179. (define-key "N" #'repeat-search *message-keymap*)
  180. (define-key "npage" #'message-scroll-next-page *message-keymap*)
  181. (define-key "ppage" #'message-scroll-previous-page *message-keymap*)
  182. (define-key "|" #'send-to-pipe *message-keymap*)
  183. ;; gemini viewer keymap
  184. (define-key "up" #'message-scroll-up *gemini-message-keymap*)
  185. (define-key "down" #'message-scroll-down *gemini-message-keymap*)
  186. (define-key "C-J" #'message-scroll-down *gemini-message-keymap*)
  187. (define-key "home" #'message-scroll-begin *gemini-message-keymap*)
  188. (define-key "end" #'message-scroll-end *gemini-message-keymap*)
  189. (define-key "/" #'message-search-regex *gemini-message-keymap*)
  190. (define-key "N" #'repeat-search *gemini-message-keymap*)
  191. (define-key "npage" #'message-scroll-next-page *gemini-message-keymap*)
  192. (define-key "ppage" #'message-scroll-previous-page *gemini-message-keymap*)
  193. (define-key "l" #'open-message-link *gemini-message-keymap*)
  194. (define-key "b" #'gemini-history-back *gemini-message-keymap*)
  195. (define-key "U" #'gemini-view-source *gemini-message-keymap*)
  196. (define-key "d" #'gemini-open-streams-window *gemini-message-keymap*)
  197. (define-key "c" #'gemini-open-certificates-window *gemini-message-keymap*)
  198. (define-key "r" #'gemini-refresh-page *gemini-message-keymap*)
  199. (define-key "s" #'gemini-subscribe-gemlog *gemini-message-keymap*)
  200. (define-key "p" #'message-toggle-preformatted-block *gemini-message-keymap*)
  201. (define-key "t" #'next-tour-link *gemini-message-keymap*)
  202. (define-key "O" #'open-gemini-toc *gemini-message-keymap*)
  203. (define-key "T" #'show-tour-links *gemini-message-keymap*)
  204. (define-key "|" #'send-to-pipe *gemini-message-keymap*)
  205. ;; gemini page table of contents keymap
  206. (define-key "up" #'gemini-toc-scroll-up *gemini-toc-keymap*)
  207. (define-key "down" #'gemini-toc-scroll-down *gemini-toc-keymap*)
  208. (define-key "C-J" #'gemini-toc-jump-to-entry *gemini-toc-keymap*)
  209. (define-key "q" #'gemini-toc-close *gemini-toc-keymap*)
  210. ;; gemini stream window keymap
  211. (define-key "a" #'gemini-abort-download *gemini-downloads-keymap*)
  212. (define-key "up" #'gemini-streams-window-up *gemini-downloads-keymap*)
  213. (define-key "down" #'gemini-streams-window-down *gemini-downloads-keymap*)
  214. (define-key "q" #'gemini-streams-window-close *gemini-downloads-keymap*)
  215. (define-key "C-J" #'gemini-streams-window-open-stream *gemini-downloads-keymap*)
  216. ;; gemini certificates window keymap
  217. (define-key "up" #'gemini-certificate-window-go-up *gemini-certificates-keymap*)
  218. (define-key "down" #'gemini-certificate-window-go-down *gemini-certificates-keymap*)
  219. (define-key "q" #'gemini-close-certificate-window *gemini-certificates-keymap*)
  220. (define-key "C-J" #'gemini-delete-certificate *gemini-certificates-keymap*)
  221. ;; gemini subscription window
  222. (define-key "C-J" #'show-gemlog-to-screen *gemlog-subscription-keymap*)
  223. (define-key "up" #'gemlogs-subscription-go-up *gemlog-subscription-keymap*)
  224. (define-key "down" #'gemlogs-subscription-go-down *gemlog-subscription-keymap*)
  225. (define-key "q" #'close-gemlog-window *gemlog-subscription-keymap*)
  226. (define-key "d" #'gemlog-cancel-subscription *gemlog-subscription-keymap*)
  227. ;; tags keymap
  228. (define-key "up" #'tag-go-up *tags-keymap*)
  229. (define-key "down" #'tag-go-down *tags-keymap*)
  230. (define-key "C-J" #'open-tag-folder *tags-keymap*)
  231. (define-key "U" #'unsubscribe-to-hash *tags-keymap*)
  232. (define-key "r" #'refresh-tags *tags-keymap*)
  233. ;; conversations keymap
  234. (define-key "C-c c" #'change-conversation-name *conversations-keymap*)
  235. (define-key "C-J" #'goto-conversation *conversations-keymap*)
  236. (define-key "up" #'conversation-go-up *conversations-keymap*)
  237. (define-key "down" #'conversation-go-down *conversations-keymap*)
  238. (define-key "dc" #'delete-conversation *conversations-keymap*)
  239. (define-key "I" #'ignore-conversation *conversations-keymap*)
  240. ;; attachments keymap
  241. (define-key "C-J" #'open-message-attach-perform-opening *open-attach-keymap*)
  242. (define-key "up" #'open-message-attach-go-up *open-attach-keymap*)
  243. (define-key "down" #'open-message-attach-go-down *open-attach-keymap*)
  244. (define-key "q" #'close-open-attach-window *open-attach-keymap*)
  245. ;; message links keymap
  246. (define-key "C-J" #'open-message-link-perform-opening *open-message-link-keymap*)
  247. (define-key "up" #'open-message-link-go-up *open-message-link-keymap*)
  248. (define-key "down" #'open-message-link-go-down *open-message-link-keymap*)
  249. (define-key "q" #'close-open-message-link-window *open-message-link-keymap*)
  250. (define-key "e" #'open-message-link-open-enqueue *open-message-link-keymap*)
  251. (define-key "/" #'search-link-window *open-message-link-keymap*)
  252. (define-key "N" #'repeat-search *open-message-link-keymap*)
  253. (define-key "t" #'tour-mode-link *open-message-link-keymap*)
  254. ;; chats list window
  255. (define-key "r" #'refresh-chat-messages *chats-list-keymap*)
  256. (define-key "R" #'refresh-chats *chats-list-keymap*)
  257. (define-key "q" #'close-chats-list-window *chats-list-keymap*)
  258. (define-key "C-J" #'show-chat-to-screen *chats-list-keymap*)
  259. (define-key "l" #'change-chat-label *chats-list-keymap*)
  260. (define-key "c" #'chat-create-new *chats-list-keymap*)
  261. (define-key "up" #'chat-list-go-up *chats-list-keymap*)
  262. (define-key "down" #'chat-list-go-down *chats-list-keymap*)
  263. ;; chat window
  264. (defun write-to-chat ()
  265. (chat-loop (message-window:metadata specials:*message-window*)))
  266. (define-key "M-c" #'write-to-chat *chat-message-keymap*)
  267. (define-key "up" #'message-scroll-up *chat-message-keymap*)
  268. (define-key "down" #'message-scroll-down *chat-message-keymap*)
  269. (define-key "home" #'message-scroll-begin *chat-message-keymap*)
  270. (define-key "end" #'message-scroll-end *chat-message-keymap*)
  271. (define-key "/" #'message-search-regex *chat-message-keymap*)
  272. (define-key "npage" #'message-scroll-next-page *chat-message-keymap*)
  273. (define-key "ppage" #'message-scroll-previous-page *chat-message-keymap*)
  274. (define-key "a" #'open-chat-link-window *chat-message-keymap*)
  275. ;;;; hooks
  276. ;; this module will install an hook to rewrite urls; By default it
  277. ;; does nothing, see the source for configuration
  278. (load-module "rewrite-message-urls.lisp")
  279. ;;; this hooks will skips toots with contain less than 20 words
  280. ;;; (note: it is commented out)
  281. ;; (hooks:add-hook 'hooks:*skip-message-hook*
  282. ;; (lambda (toot timeline folder kind localp)
  283. ;; (declare (ignore timeline folder kind localp))
  284. ;; (when-let* ((text (html-utils:html->text (tooter:content toot)
  285. ;; :add-link-footnotes nil))
  286. ;; (trimmed (text-utils:trim-blanks text))
  287. ;; (word-counts (length (text-utils:split-words trimmed))))
  288. ;; (< word-counts 10))))