Compare commits
1 Commits
main
...
warn-key-r
Author | SHA1 | Date | |
---|---|---|---|
4e666d5c6b |
2
.achievements
Normal file
2
.achievements
Normal file
File diff suppressed because one or more lines are too long
33
.gitignore
vendored
33
.gitignore
vendored
@ -1,4 +1,3 @@
|
||||
/customizations.el
|
||||
*~
|
||||
/session*
|
||||
/tramp
|
||||
@ -18,12 +17,6 @@
|
||||
/smex-items
|
||||
/var/
|
||||
/anaconda-mode/
|
||||
/.last-package-update-day
|
||||
/eln-cache
|
||||
/.lsp-session-v1
|
||||
/.dap-breakpoints
|
||||
/elpy
|
||||
|
||||
# All hail use-package!
|
||||
/elpa/
|
||||
|
||||
@ -37,29 +30,3 @@
|
||||
|
||||
# Newsticker
|
||||
/newsticker
|
||||
|
||||
# The “compiled” version of the Org configuration
|
||||
/configuration.el
|
||||
/bookmarks
|
||||
|
||||
/org-caldav-*.el
|
||||
|
||||
# Forge database
|
||||
/forge-database.sqlite
|
||||
/forge-database-v*.sql
|
||||
/forge-database-v*.sqlite
|
||||
|
||||
# request.el cookie jars
|
||||
/request/curl-cookie-jar
|
||||
|
||||
# Quelpa stuff
|
||||
/quelpa
|
||||
|
||||
# Transient history
|
||||
/transient/history.el
|
||||
|
||||
# Mastodon token list
|
||||
/mastodon.plstore
|
||||
/org-roam.db
|
||||
/.org-id-locations
|
||||
/projects
|
||||
|
101
.mc-lists.el
101
.mc-lists.el
@ -3,75 +3,38 @@
|
||||
|
||||
(setq mc/cmds-to-run-for-all
|
||||
'(
|
||||
avy-goto-char
|
||||
backward-sexp
|
||||
c-electric-brace
|
||||
c-electric-colon
|
||||
c-electric-paren
|
||||
c-electric-semi&comma
|
||||
c-electric-star
|
||||
c-indent-line-or-region
|
||||
delete-indentation
|
||||
downcase-region
|
||||
drag-stuff-down
|
||||
electric-newline-and-maybe-indent
|
||||
forward-sexp
|
||||
gpolonkai/duplicate-line
|
||||
gpolonkai/goto-next-char
|
||||
gpolonkai/move-to-beginning-of-line
|
||||
gpolonkai/move-to-end-of-line
|
||||
gpolonkai/org-space-key
|
||||
gpolonkai/toggle-char-case
|
||||
hungry-delete-backward
|
||||
hungry-delete-forward
|
||||
indent-for-tab-command
|
||||
kill-region
|
||||
kill-sexp
|
||||
kill-visual-line
|
||||
kmacro-end-or-call-macro
|
||||
magit-status
|
||||
org-cycle
|
||||
org-delete-indentation
|
||||
org-end-of-line
|
||||
org-force-self-insert
|
||||
org-kill-line
|
||||
org-meta-return
|
||||
org-return
|
||||
org-self-insert-command
|
||||
org-yank
|
||||
overwrite-mode
|
||||
sachachua/fill-or-unfill-paragraph
|
||||
sp-backward-delete-char
|
||||
sp-backward-kill-word
|
||||
sp-delete-char
|
||||
sp-kill-hybrid-sexp
|
||||
sp-kill-region
|
||||
sp-kill-word
|
||||
sp-remove-active-pair-overlay
|
||||
sp-rewrap-sexp
|
||||
sp-unwrap-sexp
|
||||
toggle-char-case
|
||||
upcase-region
|
||||
wdired--self-insert
|
||||
yaml-electric-bar-and-angle
|
||||
yaml-electric-dash-and-dot
|
||||
))
|
||||
avy-goto-char
|
||||
c-electric-brace
|
||||
c-electric-semi&comma
|
||||
c-indent-line-or-region
|
||||
electric-newline-and-maybe-indent
|
||||
gpolonkai/move-to-beginning-of-line
|
||||
gpolonkai/move-to-end-of-line
|
||||
hungry-delete-backward
|
||||
hungry-delete-forward
|
||||
indent-for-tab-command
|
||||
kill-region
|
||||
org-cycle
|
||||
org-end-of-line
|
||||
org-kill-line
|
||||
org-return
|
||||
org-self-insert-command
|
||||
org-space-key
|
||||
sp-backward-delete-char
|
||||
sp-backward-kill-word
|
||||
sp-delete-char
|
||||
))
|
||||
|
||||
(setq mc/cmds-to-run-once
|
||||
'(
|
||||
ace-jump-done
|
||||
ace-jump-move
|
||||
ace-mc-add-char
|
||||
ace-mc-add-multiple-cursors
|
||||
ace-mc-add-single-cursor
|
||||
ace-mc-do-keyboard-reset
|
||||
ace-mc-quick-exchange
|
||||
counsel-M-x
|
||||
drag-stuff-right
|
||||
end-of-buffer
|
||||
helm-M-x
|
||||
helm-confirm-and-exit-minibuffer
|
||||
helm-find-files
|
||||
smartparens-strict-mode
|
||||
suspend-frame
|
||||
))
|
||||
ace-jump-move
|
||||
ace-mc-add-char
|
||||
ace-mc-add-multiple-cursors
|
||||
ace-mc-add-single-cursor
|
||||
ace-mc-do-keyboard-reset
|
||||
drag-stuff-right
|
||||
end-of-buffer
|
||||
helm-M-x
|
||||
helm-find-files
|
||||
smartparens-strict-mode
|
||||
))
|
||||
|
155
customizations.el
Normal file
155
customizations.el
Normal file
@ -0,0 +1,155 @@
|
||||
(custom-set-variables
|
||||
;; custom-set-variables was added by Custom.
|
||||
;; If you edit it by hand, you could mess it up, so be careful.
|
||||
;; Your init file should contain only one such instance.
|
||||
;; If there is more than one, they won't work right.
|
||||
'(background-color "#7f7f7f")
|
||||
'(background-mode dark)
|
||||
'(blink-cursor-mode t)
|
||||
'(column-number-mode t)
|
||||
'(cursor-color "#5c5cff")
|
||||
'(cursor-type (quote bar))
|
||||
'(custom-enabled-themes (quote (tango-dark)))
|
||||
'(custom-file (concat user-emacs-directory "customizations.el"))
|
||||
'(custom-safe-themes
|
||||
(quote
|
||||
("3c83b3676d796422704082049fc38b6966bcad960f896669dfc21a7a37a748fa" "a27c00821ccfd5a78b01e4f35dc056706dd9ede09a8b90c6955ae6a390eb1c1e" default)))
|
||||
'(echo-keystrokes 0.1)
|
||||
'(fill-column 76)
|
||||
'(foreground-color "#5c5cff")
|
||||
'(indent-tabs-mode nil)
|
||||
'(indicate-empty-lines t)
|
||||
'(inhibit-startup-echo-area-message (user-login-name))
|
||||
'(inhibit-startup-screen t)
|
||||
'(initial-scratch-message nil)
|
||||
'(package-selected-packages
|
||||
(quote
|
||||
(ace-mc
|
||||
ace-popup-menu
|
||||
ace-window
|
||||
achievements
|
||||
ag
|
||||
alert
|
||||
anaconda-mode
|
||||
anzu
|
||||
auto-highlight-symbol
|
||||
auto-package-update
|
||||
auto-virtualenv
|
||||
avy
|
||||
beacon
|
||||
bind-key
|
||||
cheatsheet
|
||||
coffee-mode
|
||||
command-log-mode
|
||||
company
|
||||
company-anaconda
|
||||
company-c-headers
|
||||
company-emoji
|
||||
company-restclient
|
||||
company-shell
|
||||
diminish
|
||||
dired-k
|
||||
drag-stuff
|
||||
electric-case
|
||||
electric-spacing
|
||||
emamux
|
||||
eshell-fringe-status
|
||||
eshell-prompt-extras
|
||||
expand-region
|
||||
fill-column-indicator
|
||||
flycheck
|
||||
flycheck-pkg-config
|
||||
flymake-python-pyflakes
|
||||
focus
|
||||
form-feed
|
||||
ggtags
|
||||
git-gutter-fringe
|
||||
git-messenger
|
||||
git-timemachine
|
||||
gitconfig-mode
|
||||
gitignore-mode
|
||||
gitlab
|
||||
gnugo
|
||||
gobgen
|
||||
google
|
||||
goto-last-change
|
||||
helm
|
||||
helm-ag
|
||||
helm-c-yasnippet
|
||||
helm-chrome
|
||||
helm-company
|
||||
helm-descbinds
|
||||
helm-describe-modes
|
||||
helm-flycheck
|
||||
helm-flyspell
|
||||
helm-github-stars
|
||||
helm-google
|
||||
helm-gtags
|
||||
helm-hunks
|
||||
helm-projectile
|
||||
helm-pydoc
|
||||
helm-smex
|
||||
helm-swoop
|
||||
helm-unicode
|
||||
highlight-indent-guides
|
||||
hl-todo
|
||||
hungarian-holidays
|
||||
hungry-delete
|
||||
hyde
|
||||
id-manager
|
||||
identica-mode
|
||||
jinja2-mode
|
||||
js2-mode
|
||||
json-mode
|
||||
kanban
|
||||
magit
|
||||
magit-gerrit
|
||||
magithub
|
||||
markdown-mode
|
||||
mc-extras
|
||||
multiple-cursors
|
||||
ng2-mode
|
||||
nyan-mode
|
||||
nyan-prompt
|
||||
org
|
||||
org-bullets
|
||||
org-jekyll
|
||||
org-projectile
|
||||
org-random-todo
|
||||
org-rtm
|
||||
origami
|
||||
plantuml-mode
|
||||
projectile
|
||||
rainbow-delimiters
|
||||
rainbow-mode
|
||||
restclient
|
||||
restclient-helm
|
||||
sass-mode
|
||||
smart-mode-line
|
||||
smart-mode-line-powerline-theme
|
||||
smartparens
|
||||
spinner
|
||||
sx
|
||||
typescript-mode
|
||||
use-package
|
||||
vala-mode
|
||||
vala-snippets
|
||||
wakatime-mode
|
||||
xlicense
|
||||
yaml-mode
|
||||
yasnippet
|
||||
zone-nyan
|
||||
zygospore)))
|
||||
'(sgml-basic-offset 4)
|
||||
'(show-trailing-whitespace t)
|
||||
'(tab-width 4))
|
||||
(custom-set-faces
|
||||
;; custom-set-faces was added by Custom.
|
||||
;; If you edit it by hand, you could mess it up, so be careful.
|
||||
;; Your init file should contain only one such instance.
|
||||
;; If there is more than one, they won't work right.
|
||||
'(default ((t (:family "Hack" :foundry "simp" :slant normal :weight normal :height 98 :width normal))))
|
||||
'(aw-leading-char-face ((t (:inherit ace-jump-face-foreground :height 2.0))))
|
||||
'(hl-line ((t (:inherit nil :background "gray25"))))
|
||||
'(trailing-whitespace ((t (:inherit nil :background "red1"))))
|
||||
'(whitespace-line ((t (:inherit nil :background "orange4")))))
|
@ -1 +0,0 @@
|
||||
alias git git --no-pager $*
|
@ -1,2 +1 @@
|
||||
03618 Thu Aug 16 09:29:39 2018 Gergely Polonkai <gergely@polonkai.eu>
|
||||
02667 Wed Oct 5 09:52:44 2016 Gergely Polonkai <gergely@polonkai.eu>
|
||||
|
@ -1 +0,0 @@
|
||||
00000 Thu Aug 16 09:43:46 2018 Gergely Polonkai <gergely@polonkai.eu>
|
166
lisp/buf-manipulation.el
Normal file
166
lisp/buf-manipulation.el
Normal file
@ -0,0 +1,166 @@
|
||||
;; Some custom functions for buffer content manipulation
|
||||
|
||||
(defun delete-current-line ()
|
||||
"Kill the whole line on which point is"
|
||||
(interactive)
|
||||
|
||||
(beginning-of-line)
|
||||
(kill-line 1))
|
||||
|
||||
(defun copy-func-prototype ()
|
||||
"Copy the current function's prototype to the kill-ring"
|
||||
|
||||
(interactive)
|
||||
|
||||
(save-excursion
|
||||
(beginning-of-defun)
|
||||
(setq protocopy-begin (point))
|
||||
(forward-list)
|
||||
(setq protocopy-end (point))
|
||||
(kill-ring-save protocopy-begin protocopy-end)))
|
||||
|
||||
(defun duplicate-line()
|
||||
"Duplicate line at point."
|
||||
|
||||
(interactive)
|
||||
|
||||
(save-excursion
|
||||
(move-beginning-of-line 1)
|
||||
(kill-line)
|
||||
(yank)
|
||||
(open-line 1)
|
||||
(next-line 1)
|
||||
(yank)))
|
||||
|
||||
(defun toggle-char-case (arg-move-point)
|
||||
"Toggle the case of the char after point. Based on Xah's toggle letter
|
||||
case defun version 2015-12-22
|
||||
|
||||
URL `http://ergoemacs.org/emacs/modernization_upcase-word.html'
|
||||
Version 2016-02-16"
|
||||
(interactive "P")
|
||||
(let ((case-fold-search nil))
|
||||
(cond
|
||||
((looking-at "[[:lower:]]") (upcase-region (point) (1+ (point))))
|
||||
((looking-at "[[:upper:]]") (downcase-region (point) (1+ (point)))))
|
||||
(cond
|
||||
(arg-move-point (right-char)))))
|
||||
|
||||
; Copied from http://whattheemacsd.com/editing-defuns.el-01.html
|
||||
(defun open-line-below ()
|
||||
"Open a new line below point."
|
||||
|
||||
(interactive)
|
||||
|
||||
(end-of-line)
|
||||
(newline)
|
||||
(indent-for-tab-command))
|
||||
|
||||
(defun open-line-above ()
|
||||
"Open a new line above point."
|
||||
|
||||
(interactive)
|
||||
|
||||
(beginning-of-line)
|
||||
(newline)
|
||||
(forward-line -1)
|
||||
(indent-for-tab-command))
|
||||
|
||||
; Copied from http://whattheemacsd.com/file-defuns.el-01.html
|
||||
(defun rename-current-buffer-file ()
|
||||
"Renames current buffer and file it is visiting."
|
||||
(interactive)
|
||||
|
||||
(let ((name (buffer-name))
|
||||
(filename (buffer-file-name)))
|
||||
(if (not (and filename (file-exists-p filename)))
|
||||
(error "Buffer '%s' is not visiting a file!" name)
|
||||
(let ((new-name (read-file-name "New name: " filename)))
|
||||
(if (get-buffer new-name)
|
||||
(error "A buffer named '%s' already exists!" new-name)
|
||||
(rename-file filename new-name 1)
|
||||
(rename-buffer new-name)
|
||||
(set-visited-file-name new-name)
|
||||
; TODO: this is suspicious for me…
|
||||
(set-buffer-modified-p nil)
|
||||
(message "File '%s' successfully renamed to '%s'"
|
||||
name (file-name-nondirectory new-name)))))))
|
||||
|
||||
; Copied from http://whattheemacsd.com/file-defuns.el-02.html
|
||||
(defun delete-current-buffer-file ()
|
||||
"Removes file connected to current buffer and kills the
|
||||
buffer."
|
||||
(interactive)
|
||||
|
||||
(let ((filename (buffer-file-name))
|
||||
(name (buffer-name))
|
||||
(buffer (current-buffer)))
|
||||
(if (not (and filename (file-exists-p filename)))
|
||||
(kill-buffer buffer)
|
||||
(when (yes-or-no-p "Are you sure you want to remove this file? ")
|
||||
(delete-file filename)
|
||||
(kill-buffer buffer)
|
||||
(message "File '%s' successfully removed" filename)))))
|
||||
|
||||
; delete-char or close eshell
|
||||
; Copied from https://ryuslash.org/posts/C-d-to-close-eshell.html
|
||||
(defun eshell-C-d ()
|
||||
"Either call `delete-char' interactively or quit."
|
||||
(interactive)
|
||||
|
||||
(condition-case err
|
||||
(call-interactively #'delete-char)
|
||||
(error (if (and (eq (car err) 'end-of-buffer)
|
||||
(looking-back eshell-prompt-regexp))
|
||||
(kill-buffer)
|
||||
(signal (car err) (cdr err))))))
|
||||
|
||||
(defun æ-kill-or-copy-whole-line (kill)
|
||||
"Kill or copy the whole line point is on.
|
||||
|
||||
If KILL is non-nil, the line gets killed. Otherwise, it gets just
|
||||
copied to the kill-ring."
|
||||
(interactive "P")
|
||||
|
||||
(if kill
|
||||
(kill-whole-line)
|
||||
(let ((beginning (progn (beginning-of-line) (point)))
|
||||
(end (progn (end-of-line) (point))))
|
||||
(copy-region-as-kill beginning end))))
|
||||
|
||||
(defun gpolonkai/move-to-beginning-of-line ()
|
||||
"Move to different beginnings of the line; in order: beginning
|
||||
of the visual line if `visual-line-mode' is active, the first
|
||||
non-whitespace (indentation), the actual beginning of the line.
|
||||
This function will jump between the first character and the
|
||||
indentation if used multiple times.
|
||||
|
||||
Inspired by Bozhidar Batsov's solution:
|
||||
http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/"
|
||||
(interactive)
|
||||
(let ((last-pos (point)))
|
||||
(when visual-line-mode
|
||||
(beginning-of-visual-line))
|
||||
(when (= (point) last-pos)
|
||||
(back-to-indentation))
|
||||
(when (= (point) last-pos)
|
||||
(beginning-of-line))
|
||||
(when (and (eq major-mode 'org-mode)
|
||||
(= (point) last-pos))
|
||||
(org-beginning-of-line))
|
||||
(when (= (point) last-pos)
|
||||
(back-to-indentation))))
|
||||
|
||||
(defun gpolonkai/move-to-end-of-line ()
|
||||
"Move to the end of the line. If `visual-line-mode' is active,
|
||||
jump to the end of the visual line first. The jump to the
|
||||
actual end of the line."
|
||||
(interactive)
|
||||
(let ((last-pos (point)))
|
||||
(when visual-line-mode
|
||||
(end-of-visual-line))
|
||||
(when (= (point) last-pos)
|
||||
(end-of-line))
|
||||
(when (and (eq major-mode 'org-mode)
|
||||
(= (point) last-pos))
|
||||
(org-end-of-line))))
|
34
lisp/enclose-string.el
Normal file
34
lisp/enclose-string.el
Normal file
@ -0,0 +1,34 @@
|
||||
(defun æ-enclose-region (character &optional start end)
|
||||
"Enclose region in CHARACTER. If region is empty, simply inserts
|
||||
CHARACTER two times and moves point between them.
|
||||
|
||||
If character is present in `insert-pair-alist', this function
|
||||
will enclose region in the corresponding pair. In this case,
|
||||
CHARACTER must be the opening member of the pair."
|
||||
|
||||
(interactive "cWhat character? \nr")
|
||||
|
||||
(setq open character close character)
|
||||
|
||||
(let ((pair (assq character insert-pair-alist)))
|
||||
(if pair
|
||||
(if (nth 2 pair)
|
||||
(setq open (nth 1 pair) close (nth 2 pair))
|
||||
(setq open (nth 0 pair) close (nth 1 pair)))))
|
||||
|
||||
(unless (and open close)
|
||||
(setq open character)
|
||||
(setq close character))
|
||||
|
||||
(unless (use-region-p)
|
||||
(setq start (point) end (point)))
|
||||
|
||||
(save-excursion
|
||||
(goto-char end)
|
||||
(insert-char close)
|
||||
|
||||
(goto-char start)
|
||||
(insert-char open))
|
||||
|
||||
(unless (use-region-p)
|
||||
(forward-char)))
|
24
lisp/file-manip.el
Normal file
24
lisp/file-manip.el
Normal file
@ -0,0 +1,24 @@
|
||||
(defun open-this-file-as-other-user (user)
|
||||
"Edit current file as USER, using `tramp' and `sudo'. If the current
|
||||
buffer is not visiting a file, prompt for a file name."
|
||||
(interactive "sEdit as user (default: root): ")
|
||||
(when (string= "" user)
|
||||
(setq user "root"))
|
||||
(let* ((filename (or buffer-file-name
|
||||
(read-file-name (format "Find file (as %s): "
|
||||
user))))
|
||||
(tramp-path (concat (format "/sudo:%s@localhost:" user) filename)))
|
||||
(if buffer-file-name
|
||||
(find-alternate-file tramp-path)
|
||||
(find-file tramp-path))))
|
||||
|
||||
(defun gpolonkai/visit-init-file ()
|
||||
"Open the init file."
|
||||
(interactive)
|
||||
(find-file-other-window user-init-file))
|
||||
|
||||
(defun gpolonkai/visit-org-index ()
|
||||
"Visit the root of Org-mode notes."
|
||||
(interactive)
|
||||
(find-file-other-window (concat (file-name-as-directory org-directory)
|
||||
"index.org")))
|
@ -1,94 +0,0 @@
|
||||
;;; flycheck-swagger-tools --- Flycheck checker for swagger-tools.
|
||||
|
||||
;; Copyright (C) 2017 Marc-André Goyette
|
||||
;; Author: Marc-André Goyette <goyette.marcandre@gmail.com>
|
||||
;; URL: https://github.com/magoyette/flycheck-swagger-tools
|
||||
;; Version: 0.1.0
|
||||
;; Package-Requires: ((emacs "25"))
|
||||
;; Keywords: swagger
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; For a full copy of the GNU General Public License
|
||||
;; see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; flycheck-swagger-tools provides a Flycheck checker for swagger-tools.
|
||||
;; This allows to validate Swagger YAML and JSON files.
|
||||
|
||||
;; The checker can be activating by requiring this package.
|
||||
|
||||
;; (require 'flycheck-swagger-tools)
|
||||
|
||||
;; By default, only the first 4000 characters of a file are scanned to
|
||||
;; find the swagger 2.0 element. To avoid stack overflow in Emacs
|
||||
;; multi-line regex, this value is necessary. The defcustom
|
||||
;; swagger-tools-predicate-regexp-match-limit can be used to change this
|
||||
;; limit. That could be necessary for YAML files with long initial comments.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'flycheck)
|
||||
|
||||
(defgroup swagger-tools nil
|
||||
"Validate swagger files with swagger-tools."
|
||||
:group 'swagger
|
||||
:prefix "swagger-tools-")
|
||||
|
||||
(defcustom swagger-tools-predicate-regexp-match-limit 4000
|
||||
"Defines the number of characters that will be scanned at the beginning of a
|
||||
buffer to find the swagger 2.0 element."
|
||||
:type 'integer
|
||||
:group 'swagger-tools)
|
||||
|
||||
;;;###autoload
|
||||
(flycheck-define-checker swagger-tools
|
||||
"A checker that uses swagger tools to validate Swagger2 JSON and YAML files.
|
||||
See URL `https://github.com/apigee-127/swagger-tools'."
|
||||
:command ("swagger-tools" "validate" source)
|
||||
:predicate
|
||||
(lambda ()
|
||||
(string-match
|
||||
"\\(.\\|\n\\)*\\([[:space:]]\\|\"\\|\\'\\)*swagger\\([[:space:]]\\|\"\\|\\'\\)*:[[:space:]]*[\"\\']2.0[\"\\'].*"
|
||||
;; Need to avoid stack overflow for multi-line regex
|
||||
(buffer-substring 1 (min (buffer-size)
|
||||
swagger-tools-predicate-regexp-match-limit))))
|
||||
:error-patterns
|
||||
((warning line-start " " (message (one-or-more not-newline)
|
||||
"is not used"
|
||||
(one-or-more not-newline))
|
||||
line-end)
|
||||
;; js-yaml error with position
|
||||
(error line-start " error: " (message) " at line " line ", column " column ":" line-end)
|
||||
;; js-yaml error without position
|
||||
(error line-start " error: " (message) ": " (one-or-more not-newline) line-end)
|
||||
;; swagger-tools error (always contain a # symbol in the message)
|
||||
(error line-start
|
||||
" "
|
||||
(message (optional (one-or-more not-newline))
|
||||
(one-or-more "#")
|
||||
(one-or-more not-newline))
|
||||
line-end))
|
||||
:error-filter
|
||||
;; Add line number 1 if the error has no line number
|
||||
(lambda (errors)
|
||||
(let ((errors (flycheck-sanitize-errors errors)))
|
||||
(dolist (err errors)
|
||||
(unless (flycheck-error-line err)
|
||||
(setf (flycheck-error-line err) 1)))
|
||||
errors))
|
||||
:modes (json-mode openapi-yaml-mode yaml-mode))
|
||||
|
||||
(add-to-list 'flycheck-checkers 'swagger-tools)
|
||||
|
||||
(provide 'flycheck-swagger-tools)
|
||||
;;; flycheck-swagger-tools.el ends here
|
24
lisp/frame-manip.el
Normal file
24
lisp/frame-manip.el
Normal file
@ -0,0 +1,24 @@
|
||||
;; Copied from http://emacs-doctor.com/emacs-strip-tease.html
|
||||
|
||||
(defvar hidden-mode-line-mode nil)
|
||||
(defvar hide-mode-line nil)
|
||||
|
||||
(define-minor-mode hidden-mode-line-mode
|
||||
"Minor mode to hide the mode-line in the current buffer."
|
||||
:init-value nil
|
||||
:global nil
|
||||
:variable hidden-mode-line-mode
|
||||
:group 'editing-basics
|
||||
(if hidden-mode-line-mode
|
||||
(setq hide-mode-line mode-line-format
|
||||
mode-line-format nil)
|
||||
(setq mode-line-format hide-mode-line
|
||||
hide-mode-line nil))
|
||||
(force-mode-line-update)
|
||||
(redraw-display)
|
||||
(when (and (called-interactively-p 'interactive)
|
||||
hidden-mode-line-mode)
|
||||
(run-with-idle-timer
|
||||
0 nil 'message
|
||||
(concat "Hidden Mode Line Mode enabled. "
|
||||
"Use M-x hidden-mode-line-mode to make mode-line appear."))))
|
65
lisp/gnu-c-header.el
Normal file
65
lisp/gnu-c-header.el
Normal file
@ -0,0 +1,65 @@
|
||||
;;; gnu-c-header.el --- function to add a header to the C files licensed under the GPL
|
||||
;; Author: Gergely Polonkai <gergely@polonkai.eu>
|
||||
;; Copyright: public domain
|
||||
;; URL: http://gergely.polonkai.eu/blog/2014/09/26/emacs-adding-gnu-c-headers
|
||||
;; Keywords: gnu, c, header, helper, utilities
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
|
||||
(defun file-name-base-with-extension (&optional filename)
|
||||
"Return the base name of the FILENAME without its directory path.
|
||||
FILENAME defaults to `buffer-file-name'."
|
||||
(file-name-nondirectory (or filename (buffer-file-name))))
|
||||
|
||||
(defun add-gnu-c-header (progname purpose)
|
||||
"Add a GNU GPL header to the current buffer"
|
||||
(interactive "sProgram name (ie: MyProgram): \nsPurpose of the file (ie: string utility functions): ")
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(insert (concat
|
||||
"/* "
|
||||
(file-name-base-with-extension buffer-file-name)
|
||||
" - "
|
||||
purpose
|
||||
" for "
|
||||
progname
|
||||
"\n"
|
||||
" *\n"
|
||||
" * Copyright (C) "
|
||||
(format-time-string "%Y" (current-time))
|
||||
" "
|
||||
(user-full-name)
|
||||
"\n"
|
||||
" *\n"))
|
||||
(let ((start (point)))
|
||||
(insert (concat
|
||||
" * "
|
||||
progname
|
||||
" is \n * free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version."))
|
||||
(let ((end (point)))
|
||||
(fill-region start end)))
|
||||
(insert (concat
|
||||
"\n"
|
||||
" *\n"))
|
||||
(let ((start (point)))
|
||||
(insert (concat
|
||||
" * "
|
||||
progname
|
||||
" is \n * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details."))
|
||||
(let ((end (point)))
|
||||
(fill-region start end)))
|
||||
(insert (concat
|
||||
"\n"
|
||||
" *\n"))
|
||||
(let ((start (point)))
|
||||
(insert " * You \n * should have received a copy of the GNU General Public License along with this software; if not, see <http://www.gnu.org/licenses/>.")
|
||||
(let ((end (point)))
|
||||
(fill-region start end)))
|
||||
(insert (concat
|
||||
"\n"
|
||||
" */\n"))
|
||||
))
|
||||
|
||||
(provide 'gnu-c-header)
|
||||
|
||||
;;; gnu-c-header.el ends here
|
@ -1,27 +0,0 @@
|
||||
;;; gp-mouse --- Extra mouse functionality
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
(require 'mouse)
|
||||
|
||||
(defun gpolonkai/event-in-current-window-p (event)
|
||||
"Check if EVENT happened in the current window."
|
||||
(let ((current-window (selected-window))
|
||||
(event-window (posn-window (event-start event))))
|
||||
(eq current-window event-window)))
|
||||
|
||||
(defun gpolonkai/mouse-set-point (click &optional promote-to-region)
|
||||
"Set mouse position.
|
||||
|
||||
If CLICK happened in an inactive window, select that window without setting point"
|
||||
(interactive "e\np")
|
||||
(if (gpolonkai/event-in-current-window-p click)
|
||||
(call-interactively 'mouse-set-point)
|
||||
(call-interactively 'mouse-select-window)))
|
||||
|
||||
(global-set-key [mouse-1] 'mouse-select-window-or-set-point)
|
||||
(global-unset-key [down-mouse-1])
|
||||
|
||||
(provide 'gp-mouse)
|
||||
;;; gp-mouse.el ends here
|
27
lisp/gpolonkai-misc.el
Normal file
27
lisp/gpolonkai-misc.el
Normal file
@ -0,0 +1,27 @@
|
||||
(defun warn-key-rebind (keymap key new-def)
|
||||
"Warn if a key is being rebound."
|
||||
(let ((global-def (global-key-binding key))
|
||||
(local-def (local-key-binding key))
|
||||
(minor-defs (minor-mode-key-binding key))
|
||||
(key-desc (key-description key)))
|
||||
(when (and global-def
|
||||
(not (numberp global-def))
|
||||
(not (equal global-def new-def)))
|
||||
(warn "'%s' from the global keymap is being rebound from '%s' to '%s'"
|
||||
key-desc
|
||||
global-def
|
||||
new-def))
|
||||
(when (and local-def
|
||||
(not (numberp local-def))
|
||||
(not (equal local-def new-def)))
|
||||
(warn "'%s' from the local keymap is being rebound from '%s' to '%s'"
|
||||
key-desc
|
||||
local-def
|
||||
new-def))
|
||||
(when minor-defs
|
||||
(dolist (binding minor-defs)
|
||||
(warn "'%s' from '%s' keymap is being rebound from '%s' to '%s'"
|
||||
key-desc
|
||||
(car binding)
|
||||
(cdr binding)
|
||||
new-def)))))
|
@ -1,65 +0,0 @@
|
||||
;;; gpolonkai/file-utils.el --- File manipulation utilities
|
||||
;;;
|
||||
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
;;; Copyright © 2025 Gergely Polonkai
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public
|
||||
;;; License along with this library; if not, write to the
|
||||
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;;; Boston, MA 02111-1307, USA.
|
||||
;;;
|
||||
;;; Commentary:
|
||||
;;;
|
||||
;;; Utility functions stolen from the Internet or written by me
|
||||
;;;
|
||||
;;; Code:
|
||||
|
||||
;; From whattheemacsd.org: http://whattheemacsd.com/file-defuns.el-01.html
|
||||
|
||||
(defun wted/rename-current-buffer-file ()
|
||||
"Renames current buffer and the file it is visiting."
|
||||
(interactive)
|
||||
|
||||
(let ((name (buffer-name))
|
||||
(filename (buffer-file-name)))
|
||||
(if (not (and filename (file-exists-p filename)))
|
||||
(error "Buffer '%s' is not visiting a file!" name)
|
||||
(let ((new-name (read-file-name "New name: " filename)))
|
||||
(if (get-buffer new-name)
|
||||
(error "A buffer named '%s' already exists!" new-name)
|
||||
(rename-file filename new-name 1)
|
||||
(rename-buffer new-name)
|
||||
(set-visited-file-name new-name)
|
||||
; TODO: this is suspicious for me…
|
||||
(set-buffer-modified-p nil)
|
||||
(message "File '%s' successfully renamed to '%s'"
|
||||
name (file-name-nondirectory new-name)))))))
|
||||
|
||||
;; From whattheemacsd.org: http://whattheemacsd.com/file-defuns.el-02.html
|
||||
|
||||
(defun wted/delete-current-buffer-file ()
|
||||
"Remove file the current buffer is visiting and kill the buffer."
|
||||
(interactive)
|
||||
|
||||
(let ((filename (buffer-file-name))
|
||||
(name (buffer-name))
|
||||
(buffer (current-buffer)))
|
||||
(if (not (and filename (file-exists-p filename)))
|
||||
(kill-buffer buffer)
|
||||
(when (yes-or-no-p "Are you sure you want to remove this file? ")
|
||||
(delete-file filename)
|
||||
(kill-buffer buffer)
|
||||
(message "File '%s' successfully removed" filename)))))
|
||||
|
||||
(provide 'gpolonkai/file-utils)
|
||||
|
||||
;;; file-utils.el ends here
|
@ -1,65 +0,0 @@
|
||||
;;; gpolonkai/magit-utils.el --- Magit related utilities
|
||||
;;;
|
||||
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
;;; Copyright © 2025 Gergely Polonkai
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public
|
||||
;;; License along with this library; if not, write to the
|
||||
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;;; Boston, MA 02111-1307, USA.
|
||||
;;;
|
||||
;;; Commentary:
|
||||
;;;
|
||||
;;; Utility functions stolen from the Internet or written by me
|
||||
;;;
|
||||
;;; Code:
|
||||
|
||||
(defun gpolonkai/magit-goto-beginning-of-section ()
|
||||
"Go to the beginning of the current Magit section."
|
||||
(interactive)
|
||||
(let ((section (magit-current-section)))
|
||||
(magit-section-goto section)))
|
||||
|
||||
(defun gpolonkai/magit-goto-end-of-section ()
|
||||
"Move to the beginning of the next visible section."
|
||||
(interactive)
|
||||
(unless (eobp)
|
||||
(let ((section (magit-current-section)))
|
||||
(if (oref section parent)
|
||||
(let ((next (and (not (oref section hidden))
|
||||
(not (= (oref section end)
|
||||
(1+ (point))))
|
||||
(car (oref section children)))))
|
||||
(while (and section (not next))
|
||||
(unless (setq next (car (magit-section-siblings section 'next)))
|
||||
(setq section (oref section parent))))
|
||||
(if next
|
||||
(magit-section-goto next)
|
||||
(end-of-buffer)))
|
||||
(magit-section-goto 1)))))
|
||||
|
||||
(defun gpolonkai/magit-find-first-link ()
|
||||
"Find the first URL in the current section."
|
||||
(interactive)
|
||||
(let ((bos (save-excursion
|
||||
(gpolonkai/magit-goto-beginning-of-section)
|
||||
(point)))
|
||||
(eos (save-excursion
|
||||
(gpolonkai/magit-goto-end-of-section)
|
||||
(point))))
|
||||
(goto-char bos)
|
||||
(when (re-search-forward "https?://" eos t)
|
||||
(goto-char (match-beginning 0)))))
|
||||
|
||||
(provide 'gpolonkai/magit-utils)
|
||||
|
||||
;;; magit-utils.el ends here
|
@ -1,88 +0,0 @@
|
||||
;;; gpolonkai/nav-utils.el --- Navigation utilities
|
||||
;;;
|
||||
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
;;; Copyright © 2025 Gergely Polonkai
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public
|
||||
;;; License along with this library; if not, write to the
|
||||
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;;; Boston, MA 02111-1307, USA.
|
||||
;;;
|
||||
;;; Commentary:
|
||||
;;;
|
||||
;;; Utility functions stolen from the Internet or written by me
|
||||
;;;
|
||||
;;; Code:
|
||||
|
||||
;; Inspired by Bozhidar Batsov's solution:
|
||||
;; http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/
|
||||
|
||||
(defun gpolonkai/move-to-beginning-of-line ()
|
||||
"Move to different beginnings of the line.
|
||||
|
||||
These are, in order:
|
||||
|
||||
- beginning of the visual line if `visual-line-mode' is active,
|
||||
- the first non-whitespace (indentation),
|
||||
- the actual beginning of the line.
|
||||
|
||||
This function will jump between the first character and the
|
||||
indentation if used multiple times."
|
||||
(interactive)
|
||||
(let ((last-pos (point)))
|
||||
(when visual-line-mode
|
||||
(beginning-of-visual-line))
|
||||
(when (= (point) last-pos)
|
||||
(back-to-indentation))
|
||||
(when (= (point) last-pos)
|
||||
(beginning-of-line))
|
||||
(when (and (eq major-mode 'org-mode)
|
||||
(= (point) last-pos))
|
||||
(org-beginning-of-line))
|
||||
(when (= (point) last-pos)
|
||||
(back-to-indentation))))
|
||||
|
||||
(defun gpolonkai/move-to-end-of-line ()
|
||||
"Move to the end of the line.
|
||||
|
||||
If `visual-line-mode' is active, jump to the end of the visual
|
||||
line first. Then jump to the actual end of the line."
|
||||
(interactive)
|
||||
(let ((last-pos (point)))
|
||||
(when visual-line-mode
|
||||
(end-of-visual-line))
|
||||
(when (= (point) last-pos)
|
||||
(end-of-line))
|
||||
(when (and (eq major-mode 'org-mode)
|
||||
(= (point) last-pos))
|
||||
(org-end-of-line))))
|
||||
|
||||
(defun gpolonkai/goto-next-char (chr)
|
||||
"Move toe the next occurence of CHR on the same line."
|
||||
(interactive "c")
|
||||
(when (search-forward (char-to-string chr) (pos-eol) t)
|
||||
(backward-char)))
|
||||
|
||||
(defun gpolonkai/beginning-of-next-word ()
|
||||
"Move to the beginning of the next word."
|
||||
(interactive)
|
||||
(let ((current-point (point)))
|
||||
(forward-word 1)
|
||||
(backward-word 1)
|
||||
|
||||
(when (<= (point) current-point)
|
||||
(forward-word 2)
|
||||
(backward-word 1))))
|
||||
|
||||
(provide 'gpolonkai/nav-utils)
|
||||
|
||||
;;; nav-utils.el ends here
|
@ -1,175 +0,0 @@
|
||||
;;; gpolonkai/org-utils.el --- Org-mode related functions
|
||||
;;;
|
||||
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
;;; Copyright © 2025 Gergely Polonkai
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public
|
||||
;;; License along with this library; if not, write to the
|
||||
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;;; Boston, MA 02111-1307, USA.
|
||||
;;;
|
||||
;;; Commentary:
|
||||
;;;
|
||||
;;; Utility functions stolen from the Internet or written by me
|
||||
;;;
|
||||
;;; Code:
|
||||
|
||||
(defun gpolonkai/org-agenda-list (&optional arg)
|
||||
"Wrapper around `org-agenda' to open my custom list.
|
||||
|
||||
ARG is passed verbatim to `org-agenda'."
|
||||
(interactive "P")
|
||||
(org-agenda arg "c"))
|
||||
|
||||
(defun gpolonkai/org-insert-current-timestamp (&optional arg)
|
||||
"Insert the current timestamp.
|
||||
|
||||
ARG is passed verbatim to `org-time-stamp'."
|
||||
(interactive "P")
|
||||
(org-time-stamp '(16) arg))
|
||||
|
||||
(defcustom gpolonkai/org-dbl-space-punct-marks (list ?. ?! ?? ?…)
|
||||
"Punctuation marks after which the space key should insert two space characters."
|
||||
:type '(set character))
|
||||
|
||||
(defun gpolonkai/org-space-key (&optional arg)
|
||||
"Insert two spaces after certain markers.
|
||||
|
||||
ARG will be passed down verbatim to `self-insert-command'."
|
||||
(interactive "p")
|
||||
|
||||
(when (and
|
||||
(not (org-in-block-p '("src")))
|
||||
(looking-back (rx-to-string `(any,@ gpolonkai/org-dbl-space-punct-marks)) nil))
|
||||
(call-interactively 'self-insert-command arg))
|
||||
(call-interactively 'self-insert-command arg))
|
||||
|
||||
;; The whole idea comes from https://blog.aaronbieber.com/2016/09/24/an-agenda-for-life-with-org-mode.html
|
||||
;; which i use almost verbatim, hence the ~air-~ prefix.
|
||||
(defun air-org-skip-subtree-if-priority (priority)
|
||||
"Skip an agenda subtree if it has a priority of PRIORITY.
|
||||
|
||||
PRIORITY may be one of the characters ?A, ?B, or ?C."
|
||||
(let ((subtree-end (save-excursion (org-end-of-subtree t)))
|
||||
(pri-value (* 1000 (- org-lowest-priority priority)))
|
||||
(pri-current (org-get-priority (thing-at-point 'line t))))
|
||||
(if (= pri-value pri-current)
|
||||
subtree-end
|
||||
nil)))
|
||||
|
||||
(defun air-org-skip-subtree-if-habit ()
|
||||
"Skip an agenda entry if it has a STYLE property equal to \"habit\"."
|
||||
(let ((subtree-end (save-excursion (org-end-of-subtree t))))
|
||||
(if (string= (org-entry-get nil "STYLE") "habit")
|
||||
subtree-end
|
||||
nil)))
|
||||
|
||||
(defun gpolonkai/org-skip-subtree-if-state (state)
|
||||
"Skip an agenda entry if its state is STATE."
|
||||
(let ((subtree-end (save-excursion (org-end-of-subtree t))))
|
||||
(if (string= (org-get-todo-state) state)
|
||||
subtree-end
|
||||
nil)))
|
||||
|
||||
(defun gpolonkai/org-insert-heading-created (&optional arg)
|
||||
"Insert a heading with the CREATED property set to the current time.
|
||||
|
||||
This emulates how Orgzly works.
|
||||
|
||||
If ARG is set, insert a subheading; otherwise insert a heading."
|
||||
(interactive "p")
|
||||
(let* ((org-insert-heading-respect-content t)
|
||||
(format-string (concat "[" (substring (cdr org-time-stamp-formats) 1 -1) "]"))
|
||||
(timestamp (format-time-string format-string (current-time))))
|
||||
(if (> arg 1)
|
||||
(org-insert-subheading '(4))
|
||||
(org-insert-heading))
|
||||
(org-set-property "CREATED" timestamp)))
|
||||
|
||||
;; The following functions, prefixed with `f-ediff', are from the org-mode mailing list (see archive
|
||||
;; at https://list.orgmode.org/loom.20130801T011342-572@post.gmane.org/).
|
||||
|
||||
(defun f-ediff-org-showhide (buf command &rest cmdargs)
|
||||
"If buffer BUF exists and in `org-mode', execute COMMAND with CMDARGS."
|
||||
(when buf
|
||||
(when (eq (buffer-local-value 'major-mode (get-buffer buf)) 'org-mode)
|
||||
(save-excursion
|
||||
(set-buffer buf)
|
||||
(apply command cmdargs)))))
|
||||
|
||||
(defun f-ediff-org-unfold-tree-element ()
|
||||
"Unfold tree at diff location."
|
||||
(f-ediff-org-showhide ediff-buffer-A 'org-reveal)
|
||||
(f-ediff-org-showhide ediff-buffer-B 'org-reveal)
|
||||
(f-ediff-org-showhide ediff-buffer-C 'org-reveal))
|
||||
|
||||
(defun f-ediff-org-fold-tree ()
|
||||
"Fold tree back to top level."
|
||||
(f-ediff-org-showhide ediff-buffer-A 'hide-sublevels 1)
|
||||
(f-ediff-org-showhide ediff-buffer-B 'hide-sublevels 1)
|
||||
(f-ediff-org-showhide ediff-buffer-C 'hide-sublevels 1))
|
||||
|
||||
;; From the Howardism blog: http://www.howardism.org/Technical/Emacs/capturing-content.html
|
||||
|
||||
(defun ha/org-capture-fileref-snippet (f type headers func-name)
|
||||
"Capture a snippet from a file, with the filename and the location within.
|
||||
|
||||
F is the name of the file the capture is coming from.
|
||||
|
||||
TYPE is the type of the block to be inserted (e.g. \"src\").
|
||||
|
||||
HEADERS are the headers appended to the block's #begin line (usually starting
|
||||
with the language’s mode).
|
||||
|
||||
FUNC-NAME is the name of the function point is in, if any."
|
||||
(let* ((code-snippet
|
||||
(buffer-substring-no-properties (mark) (- (point) 1)))
|
||||
(file-name (buffer-file-name))
|
||||
(file-base (file-name-nondirectory file-name))
|
||||
(line-number (line-number-at-pos (region-beginning)))
|
||||
(initial-txt (if (null func-name)
|
||||
(format "From [[file:%s::%s][%s]]:"
|
||||
file-name line-number file-base)
|
||||
(format "From ~%s~ (in [[file:%s::%s][%s]]):"
|
||||
func-name file-name line-number
|
||||
file-base))))
|
||||
(format "
|
||||
%s
|
||||
|
||||
,#+begin_%s %s
|
||||
%s
|
||||
,#+end_%s" initial-txt type headers code-snippet type)))
|
||||
|
||||
(defun ha/org-capture-clip-snippet (f)
|
||||
"Capture the selected text as an EXAMPLE block.
|
||||
|
||||
The captured text also contains a backlink to the file.
|
||||
|
||||
F is the file the capture is coming from."
|
||||
(with-current-buffer (find-buffer-visiting f)
|
||||
(ha/org-capture-fileref-snippet f "example" "" nil)))
|
||||
|
||||
(defun ha/org-capture-code-snippet (f)
|
||||
"Capture the selected text as an SRC block.
|
||||
|
||||
The captured block will have the correct language set, and contains a backlink
|
||||
to the file.
|
||||
|
||||
F is the file the capture is coming from."
|
||||
(with-current-buffer (find-buffer-visiting f)
|
||||
(let ((org-src-mode (replace-regexp-in-string "-mode" "" (format "%s" major-mode)))
|
||||
(func-name (which-function)))
|
||||
(ha/org-capture-fileref-snippet f "src" org-src-mode func-name))))
|
||||
|
||||
(provide 'gpolonkai/org-utils)
|
||||
|
||||
;;; org-utils.el ends here
|
@ -1,136 +0,0 @@
|
||||
;;; gpolonkai/text-utils.el --- Text manipulation utilities
|
||||
;;;
|
||||
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
;;; Copyright © 2025 Gergely Polonkai
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public
|
||||
;;; License along with this library; if not, write to the
|
||||
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;;; Boston, MA 02111-1307, USA.
|
||||
;;;
|
||||
;;; Commentary:
|
||||
;;;
|
||||
;;; Utility functions stolen from the Internet or written by me
|
||||
;;;
|
||||
;;; Code:
|
||||
|
||||
;; From Sacha Chua’s blog: http://pages.sachachua.com/.emacs.d/Sacha.html
|
||||
|
||||
(defun sachachua/fill-or-unfill-paragraph (&optional unfill region)
|
||||
"Fill (or unfill, if UNFILL is non-nil) paragraph (or REGION)."
|
||||
(interactive (progn
|
||||
(barf-if-buffer-read-only)
|
||||
(list (if current-prefix-arg 'unfill) t)))
|
||||
(let ((fill-column (if unfill (point-max) fill-column)))
|
||||
(fill-paragraph nil region)))
|
||||
|
||||
;; Based on Xah’s toggle letter case defun (version 2015-12-22):
|
||||
;; http://ergoemacs.org/emacs/modernization_upcase-word.html
|
||||
|
||||
(defun gpolonkai/toggle-char-case (arg-move-point)
|
||||
"Toggle the case of the char after point.
|
||||
|
||||
If prefix argument ARG-MOVE-POINT is non-nil, move point after the char."
|
||||
(interactive "P")
|
||||
(let ((case-fold-search nil))
|
||||
(cond
|
||||
((looking-at "[[:lower:]]") (upcase-region (point) (1+ (point))))
|
||||
((looking-at "[[:upper:]]") (downcase-region (point) (1+ (point)))))
|
||||
(cond
|
||||
(arg-move-point (right-char)))))
|
||||
|
||||
;; The next two functions are from whattheemacsd.com: http://whattheemacsd.com/editing-defuns.el-01.html
|
||||
|
||||
(defun gpolonkai/numeric-sort-lines (reverse beg end)
|
||||
"Sort lines in region by \"version\".
|
||||
|
||||
\"version\" is the first number found on a line.
|
||||
|
||||
If REVERSE is set, sort in reverse order.
|
||||
|
||||
BEG and END are the two ends of the region."
|
||||
(interactive "P\nr")
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(narrow-to-region beg end)
|
||||
(goto-char (point-min))
|
||||
(let ((indibit-field-text-motion t))
|
||||
(sort-subr reverse 'forward-line 'end-of-line #'gpolonkai/find-number-on-line)))))
|
||||
|
||||
(defun wted/open-line-above ()
|
||||
"Open a new line above point."
|
||||
|
||||
(interactive)
|
||||
(beginning-of-line)
|
||||
(newline)
|
||||
(forward-line -1)
|
||||
(let ((tab-always-indent t)
|
||||
(c-tab-always-indent t))
|
||||
(indent-for-tab-command)))
|
||||
|
||||
(defun wted/open-line-below ()
|
||||
"Open a new line below point."
|
||||
|
||||
(interactive)
|
||||
|
||||
(end-of-line)
|
||||
(newline)
|
||||
(let ((tab-always-indent t)
|
||||
(c-tab-always-indent t))
|
||||
(indent-for-tab-command)))
|
||||
|
||||
;; From Marcin Borkowski’s blog: http://mbork.pl/2019-02-17_Inserting_the_current_file_name_at_point
|
||||
|
||||
(defun mbork/insert-current-file-name-at-point (&optional full-path)
|
||||
"Insert the current filename at point.
|
||||
|
||||
With prefix argument, or with FULL-PATH set to non-nil, use full path of the file."
|
||||
(interactive "P")
|
||||
(let* ((buffer
|
||||
(if (minibufferp)
|
||||
(window-buffer
|
||||
(minibuffer-selected-window))
|
||||
(current-buffer)))
|
||||
(filename (buffer-file-name buffer)))
|
||||
(if filename
|
||||
(insert (if full-path filename (file-name-nondirectory filename)))
|
||||
(error (format "Buffer %s is not visiting a file" (buffer-name buffer))))))
|
||||
|
||||
;; From Emacs SE: http://emacs.stackexchange.com/a/27170/507
|
||||
|
||||
(defun e-se/query-swap-strings (from-string to-string &optional delimited start end)
|
||||
"Swap occurrences of FROM-STRING and TO-STRING.
|
||||
|
||||
DELIMITED, START, and END are passed down verbatim to `perform-replace'."
|
||||
(interactive
|
||||
(let ((common
|
||||
(query-replace-read-args
|
||||
(concat "Query swap"
|
||||
(if current-prefix-arg
|
||||
(if (eq current-prefix-arg '-) " backward" " word")
|
||||
"")
|
||||
(if (use-region-p) " in region" ""))
|
||||
nil)))
|
||||
(list (nth 0 common) (nth 1 common) (nth 2 common)
|
||||
(if (use-region-p) (region-beginning))
|
||||
(if (use-region-p) (region-end)))))
|
||||
(perform-replace
|
||||
(concat "\\(" (regexp-quote from-string) "\\)\\|" (regexp-quote to-string))
|
||||
`(replace-eval-replacement replace-quote
|
||||
(if (match-string 1)
|
||||
,to-string
|
||||
,from-string))
|
||||
t t delimited nil nil start end))
|
||||
|
||||
(provide 'gpolonkai/text-utils)
|
||||
|
||||
;;; text-utils.el ends here
|
@ -1,101 +0,0 @@
|
||||
;;; gpolonkai/utilities.el --- Utilities
|
||||
;;;
|
||||
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
;;; Copyright © 2025 Gergely Polonkai
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public
|
||||
;;; License along with this library; if not, write to the
|
||||
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;;; Boston, MA 02111-1307, USA.
|
||||
;;;
|
||||
;;; Commentary:
|
||||
;;;
|
||||
;;; Utility functions stolen from the Internet or written by me
|
||||
;;;
|
||||
;;; Code:
|
||||
|
||||
;; Make a backup filename under `user-emacs-cache-directory'
|
||||
;;
|
||||
;; Taken from http://ergoemacs.org/emacs/emacs_set_backup_into_a_directory.html
|
||||
|
||||
(defun xah/backup-file-name (fpath)
|
||||
"Return a new file path for FPATH under `user-emacs-cache-directory'."
|
||||
(let* ((backup-root-dir (expand-file-name "backup" user-emacs-cache-directory))
|
||||
(file-path (replace-regexp-in-string "[A-Za-z]:" "" fpath))
|
||||
(backup-file-path (replace-regexp-in-string "//" "/" (concat backup-root-dir file-path "~"))))
|
||||
(make-directory (file-name-directory backup-file-path) (file-name-directory backup-file-path))
|
||||
backup-file-path))
|
||||
|
||||
;; Check if we’re running under Termux
|
||||
;;
|
||||
;; We need to do things differently, if so. There’s probably a better way, though, other than checking the path of our
|
||||
;; home directory.
|
||||
|
||||
(defun gpolonkai/termux-p ()
|
||||
"Check if Emacs is running under Termux."
|
||||
(string-match-p
|
||||
(regexp-quote "/com.termux/")
|
||||
(expand-file-name "~")))
|
||||
|
||||
(defun gpolonkai/find-number-on-line ()
|
||||
"Find the first number on the current line."
|
||||
(save-excursion
|
||||
(without-restriction
|
||||
(goto-char (pos-bol))
|
||||
(when (re-search-forward "[0-9]+" (pos-eol) t)
|
||||
(number-at-point)))))
|
||||
|
||||
(defun gpolonkai/round-number-at-point-to-decimals (decimal-count)
|
||||
"Round number at point to the given decimals.
|
||||
|
||||
The number of decimals in the result is specified by DECIMAL-COUNT."
|
||||
(interactive "NDecimal count: ")
|
||||
(let ((mult (expt 10 decimal-count)))
|
||||
(replace-match (number-to-string
|
||||
(/
|
||||
(fround
|
||||
(*
|
||||
mult
|
||||
(number-at-point)))
|
||||
mult)))))
|
||||
|
||||
;; From http://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch.html
|
||||
|
||||
(defun ep/isearch-exit-other-end ()
|
||||
"Exit `isearch' at the opposite end of the string."
|
||||
(interactive)
|
||||
|
||||
(isearch-exit)
|
||||
(goto-char isearch-other-end))
|
||||
|
||||
;; From http://emacs.stackexchange.com/a/31321/507
|
||||
|
||||
(defun e-se/isearch-exit-mark-match ()
|
||||
"Exit isearch and mark the current match."
|
||||
(interactive)
|
||||
(isearch-exit)
|
||||
(push-mark isearch-other-end)
|
||||
(activate-mark))
|
||||
|
||||
(defun gpolonkai/copy-func-prototype ()
|
||||
"Copy the current function's prototype to the kill ring."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(beginning-of-defun)
|
||||
(let ((protocopy-begin (point)))
|
||||
(forward-list)
|
||||
(let ((protocopy-end (point)))
|
||||
(kill-ring-save protocopy-begin protocopy-end)))))
|
||||
|
||||
(provide 'gpolonkai/utilities)
|
||||
|
||||
;;; utilities.el ends here
|
@ -1,17 +0,0 @@
|
||||
(setq-default
|
||||
mode-line-format
|
||||
("%e"
|
||||
mode-line-front-space
|
||||
mode-line-mule-info
|
||||
mode-line-client
|
||||
mode-line-modified
|
||||
mode-line-remote
|
||||
mode-line-frame-identification
|
||||
mode-line-buffer-identification
|
||||
" "
|
||||
mode-line-position
|
||||
(vc-mode vc-mode)
|
||||
" "
|
||||
mode-line-modes
|
||||
mode-line-misc-info
|
||||
mode-line-end-spaces))
|
102
lisp/package-manip.el
Normal file
102
lisp/package-manip.el
Normal file
@ -0,0 +1,102 @@
|
||||
;;; package-manip.el --- Utility functions to check if package upgrades are available
|
||||
|
||||
;;; Commentary:
|
||||
;; I should add one.
|
||||
|
||||
;; Credits go to http://emacs.stackexchange.com/a/16407/507
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defun package-upgrade-all ()
|
||||
"Upgrade all packages automatically without showing *Packages* buffer."
|
||||
(interactive)
|
||||
(package-refresh-contents)
|
||||
(let (upgrades)
|
||||
(cl-flet ((get-version (name where)
|
||||
(let ((pkg (cadr (assq name where))))
|
||||
(when pkg
|
||||
(package-desc-version pkg)))))
|
||||
(dolist (package (mapcar #'car package-alist))
|
||||
(let ((in-archive (get-version package package-archive-contents)))
|
||||
(when (and in-archive
|
||||
(version-list-< (get-version package package-alist)
|
||||
in-archive))
|
||||
(push (cadr (assq package package-archive-contents))
|
||||
upgrades)))))
|
||||
(if upgrades
|
||||
(when (yes-or-no-p
|
||||
(message "Upgrade %d package%s (%s)? "
|
||||
(length upgrades)
|
||||
(if (= (length upgrades) 1) "" "s")
|
||||
(mapconcat #'package-desc-full-name upgrades ", ")))
|
||||
(save-window-excursion
|
||||
(dolist (package-desc upgrades)
|
||||
(let ((old-package (cadr (assq (package-desc-name package-desc)
|
||||
package-alist))))
|
||||
(package-install package-desc)
|
||||
(package-delete old-package)))))
|
||||
(message "All packages are up to date"))))
|
||||
|
||||
(defun check-todays-package-upgrade-p (&optional no-save)
|
||||
"Check if automatic package upgrade has been performed today.
|
||||
|
||||
This function reads the date of the last check from the
|
||||
\"last-package-upgrade\" file. Where this file is looked for is
|
||||
guessed as follows:
|
||||
|
||||
If `user-emacs-cache-directory' is set (e.g. by the
|
||||
`xdg-paths.el' package available from
|
||||
https://github.com/tomprince/xdg-paths-el), the timestamp file is
|
||||
opened from there. Otherwise, it will be read from
|
||||
`user-emacs-directory'
|
||||
|
||||
If NO-SAVE is 'nil', the current date will be saved to the
|
||||
timestamp file.
|
||||
|
||||
The return value of this function will be 't' if the timestamp
|
||||
file contains todays date, 'nil' otherwise."
|
||||
|
||||
(let ((tsfile-location (if (boundp 'user-emacs-cache-directory)
|
||||
user-emacs-cache-directory
|
||||
user-emacs-directory)))
|
||||
(unless (and (file-exists-p tsfile-location)
|
||||
(file-accessible-directory-p tsfile-location))
|
||||
(make-directory tsfile-location t))
|
||||
|
||||
(let ((timestamp-today t)
|
||||
(timestamp-buffer (find-file-literally
|
||||
(expand-file-name "last-package-upgrade"
|
||||
tsfile-location))))
|
||||
(with-current-buffer timestamp-buffer
|
||||
(goto-char 0)
|
||||
(unless (looking-at-p (format-time-string "%Y-%m-%d"))
|
||||
(unless no-save
|
||||
(erase-buffer)
|
||||
(insert (format-time-string "%Y-%m-%d"))
|
||||
(save-buffer 0))
|
||||
(setq timestamp-today nil))
|
||||
(kill-buffer)
|
||||
timestamp-today))))
|
||||
|
||||
(defun check-for-package-upgrades-on-day (&optional day-number)
|
||||
"Check for package upgrades if today is DAY-NUMBER.
|
||||
|
||||
DAY-NUMBER can be anything between 0 and 7, inclusive. Both 0
|
||||
and 7 denote Sunday to make both types of users happy.
|
||||
|
||||
If DAY-NUMBER is 'nil', it defaults to today's day."
|
||||
|
||||
(let ((actual-day-number (cond
|
||||
((eq day-number nil) (string-to-number (format-time-string "%u")))
|
||||
((eq day-number 0) 7)
|
||||
(t day-number))))
|
||||
(when (and (eq day-number (string-to-number (format-time-string "%u")))
|
||||
(not (check-todays-package-upgrade-p t)))
|
||||
(message "Calling")
|
||||
(when (call-interactively 'package-upgrade-all)
|
||||
(message "Called")
|
||||
(check-todays-package-upgrade-p nil)))))
|
||||
|
||||
(provide 'package-manip)
|
||||
|
||||
;;; package-manip.el ends here
|
19
lisp/round-number-to-decimals.el
Normal file
19
lisp/round-number-to-decimals.el
Normal file
@ -0,0 +1,19 @@
|
||||
(defun get-number-at-point ()
|
||||
(interactive)
|
||||
(skip-chars-backward "0123456789.-")
|
||||
(or (looking-at "[0123456789.-]+")
|
||||
(error "No number at point"))
|
||||
(string-to-number (match-string 0)))
|
||||
|
||||
(defun round-number-at-point-to-decimals (decimal-count)
|
||||
(interactive "NDecimal count: ")
|
||||
(let ((mult (expt 10 decimal-count)))
|
||||
(replace-match (number-to-string
|
||||
(/
|
||||
(fround
|
||||
(*
|
||||
mult
|
||||
(get-number-at-point)))
|
||||
mult)))))
|
||||
|
||||
(global-set-key (kbd "C-c r") 'round-number-at-point-to-decimals)
|
7
lisp/text-manip.el
Normal file
7
lisp/text-manip.el
Normal file
@ -0,0 +1,7 @@
|
||||
(defun org-space-key (&optional arg)
|
||||
"Insert two spaces after a period."
|
||||
(interactive "p")
|
||||
|
||||
(when (looking-back "[.!?…]")
|
||||
(call-interactively 'self-insert-command arg))
|
||||
(call-interactively 'self-insert-command arg))
|
@ -1,48 +1,4 @@
|
||||
;;; gpolonkai/windows.el --- Window manipulation
|
||||
;;;
|
||||
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
;;; Copyright © 2025 Gergely Polonkai
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 3 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;;; Lesser General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Lesser General Public
|
||||
;;; License along with this library; if not, write to the
|
||||
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;;; Boston, MA 02111-1307, USA.
|
||||
;;;
|
||||
;;; Commentary:
|
||||
;;;
|
||||
;;; Utility functions stolen from the Internet or written by me
|
||||
;;;
|
||||
;;; Code:
|
||||
|
||||
(defun gpolonkai/bury-window (window)
|
||||
"Quit WINDOW without killing it (effectively burying it under other windows)."
|
||||
(interactive)
|
||||
(quit-window nil window))
|
||||
|
||||
(defun gpolonkai/scroll-window-up (window)
|
||||
"Scroll WINDOW up as `scroll-up-command' would."
|
||||
(interactive)
|
||||
(save-selected-window
|
||||
(select-window window)
|
||||
(scroll-up)))
|
||||
|
||||
(defun gpolonkai/scroll-window-down (window)
|
||||
"Scroll WINDOW down as `scroll-down-command' would."
|
||||
(interactive)
|
||||
(save-selected-window
|
||||
(select-window window)
|
||||
(scroll-down)))
|
||||
|
||||
(defun gpolonkai/transpose-windows (arg)
|
||||
(defun transpose-windows (arg)
|
||||
"Transpose the buffers shown in two windows."
|
||||
(interactive "p")
|
||||
(let ((selector (if (>= arg 0) 'next-window 'previous-window)))
|
||||
@ -54,8 +10,7 @@
|
||||
(select-window (funcall selector)))
|
||||
(setq arg (if (plusp arg) (1- arg) (1+ arg))))))
|
||||
|
||||
(defun gpolonkai/toggle-window-split ()
|
||||
"Toggle window split between horizontal and vertical."
|
||||
(defun toggle-window-split ()
|
||||
(interactive)
|
||||
(if (= (count-windows) 2)
|
||||
(let* ((this-win-buffer (window-buffer))
|
||||
@ -81,6 +36,21 @@
|
||||
(if this-win-2nd (other-window 1))))
|
||||
(error "This works only for two windows!")))
|
||||
|
||||
(provide 'gpolonkai/windows)
|
||||
(defun gpolonkai/scroll-window-up (window)
|
||||
"Scroll WINDOW up as `scroll-up-command' would."
|
||||
(interactive)
|
||||
(save-selected-window
|
||||
(select-window window)
|
||||
(scroll-up)))
|
||||
|
||||
;;; windows.el ends here
|
||||
(defun gpolonkai/scroll-window-down (window)
|
||||
"Scroll WINDOW down as `scroll-down-command' would."
|
||||
(interactive)
|
||||
(save-selected-window
|
||||
(select-window window)
|
||||
(scroll-down)))
|
||||
|
||||
(defun gpolonkai/bury-window (window)
|
||||
"Quit WINDOW without killing it."
|
||||
(interactive)
|
||||
(quit-window nil window))
|
@ -40,7 +40,7 @@
|
||||
;;; user-documents-directory ~/Documents
|
||||
;;;
|
||||
;;; Some convenience functions are defined to locate files in these
|
||||
;;; directories and to add user Lisp to load-path.
|
||||
;;; directories and to add user lisp to load-path.
|
||||
;;;
|
||||
;;; Some advantages are:
|
||||
;;;
|
||||
@ -114,28 +114,28 @@
|
||||
;;; Code:
|
||||
|
||||
(eval-when-compile
|
||||
(require 'cl-lib))
|
||||
(require 'cl))
|
||||
|
||||
;;; Directories definition.
|
||||
(defvar user-emacs-config-directory nil
|
||||
"The directory where the Emacs user configuration files are stored at.")
|
||||
"The directory where the emacs user configuration files are stored at.")
|
||||
|
||||
|
||||
(defvar user-emacs-data-directory nil
|
||||
"The directory where the Emacs user data and Lisp files are stored at.
|
||||
"The directory where the emacs user data and lisp files are stored at.
|
||||
|
||||
\\[user-emacs-directory] is set to this directory.")
|
||||
|
||||
|
||||
(defvar user-emacs-cache-directory nil
|
||||
"The directory where the Emacs user expendable files are stored at.
|
||||
"The directory where the emacs user expendable files are stored at.
|
||||
|
||||
Files stored here should not be missed when deleted, apart a
|
||||
temporary loss in speed.")
|
||||
|
||||
|
||||
(defvar user-emacs-lisp-directory nil
|
||||
"The directory where the user Lisp packages are stored at.
|
||||
"The directory where the user lisp packages are stored at.
|
||||
|
||||
This directory is added to \\[load-path].")
|
||||
|
||||
@ -146,73 +146,72 @@ This directory is added to \\[load-path].")
|
||||
|
||||
|
||||
(defun xdg-user-dir (dirname)
|
||||
"Given DIRNAME, run 'xdg-user-dir DIRNAME' and return the result in a string.
|
||||
"Given NAME, run 'xdg-user-dir NAME' and return the result in a string.
|
||||
|
||||
If the command fails, return NIL."
|
||||
(let ((command (concat "xdg-user-dir " dirname)))
|
||||
(if (zerop (shell-command command))
|
||||
(substring (shell-command-to-string command) 0 -1)
|
||||
(substring (shell-command-to-string command) 0 -1)
|
||||
nil)))
|
||||
|
||||
|
||||
(defun locate-user-file (filename &optional type)
|
||||
"Given a file FILENAME, locate it in the user files.
|
||||
"Given a file, locate it in the user files.
|
||||
|
||||
If TYPE is NIL or 'data, the file will be located in user-emacs-data-directory.
|
||||
|
||||
If `config', it will be located in user-emacs-config-directory.
|
||||
If 'config, it will be located in user-emacs-config-directory.
|
||||
|
||||
If `cache', it will be located in user-emacs-cache-directory.
|
||||
If 'cache, it will be located in user-emacs-cache-directory.
|
||||
|
||||
If `lisp', it will be located in user-emacs-lisp-directory.
|
||||
If 'lisp, it will be located in user-emacs-lisp-directory.
|
||||
|
||||
If `documents', it will be located in user-documents-directory.
|
||||
If 'documents, it will be located in user-documents-directory.
|
||||
|
||||
If the category is wrong, an error will be signaled."
|
||||
If the category is wrong, an error will be signaled.
|
||||
"
|
||||
(expand-file-name filename
|
||||
(cond
|
||||
((or (not type) (eq type 'data)) user-emacs-data-directory)
|
||||
((eq type 'config) user-emacs-config-directory)
|
||||
((eq type 'lisp) user-emacs-lisp-directory)
|
||||
((eq type 'cache) user-emacs-cache-directory)
|
||||
((eq type 'documents) user-documents-directory)
|
||||
(t (error "The category %s is not valid" type)))))
|
||||
(case type
|
||||
((nil data) user-emacs-data-directory)
|
||||
('config user-emacs-config-directory)
|
||||
('lisp user-emacs-lisp-directory)
|
||||
('cache user-emacs-cache-directory)
|
||||
('documents user-documents-directory)
|
||||
(t (error "The category %s is not valid" type)))))
|
||||
|
||||
|
||||
(defun locate-user-config-file (filename)
|
||||
"Given a file FILENAME, locate it in `user-emacs-config-directory`."
|
||||
"Given a file, locate it in `user-emacs-config-directory`."
|
||||
(locate-user-file filename 'config))
|
||||
|
||||
|
||||
(defun locate-user-lisp (filename)
|
||||
"Given a file FILENAME, locate it in `user-emacs-lisp-directory`."
|
||||
"Given a file, locate it in `user-emacs-lisp-directory`."
|
||||
(locate-user-file filename 'lisp))
|
||||
|
||||
|
||||
(defun add-to-path (directory &optional append)
|
||||
"Given DIRECTORY, it it exists and is a directory, add it to `load-path`.
|
||||
|
||||
APPEND is passed verbatim to `add-to-list'."
|
||||
"Given DIRECTORY, it it exists and is indeed a directory, add
|
||||
it to `load-path`."
|
||||
(interactive "D")
|
||||
(if (file-directory-p directory)
|
||||
(add-to-list 'load-path directory append)
|
||||
(error "The directory \"%s\" does not exist or isn't a directory" directory)))
|
||||
(error "The directory \"%s\" does not exist or isn't a directory." directory)))
|
||||
|
||||
|
||||
(defun add-user-lisp-to-path (directory &optional append)
|
||||
"Given DIRECTORY, if it exists and is a directory, add it to `load-path`.
|
||||
|
||||
APPEND is passed directly to `add-to-path'."
|
||||
"Given DIRECTORY, it it exists and is indeed a directory, add
|
||||
it to `load-path`."
|
||||
(interactive "D")
|
||||
(add-to-path (locate-user-lisp directory) append))
|
||||
|
||||
|
||||
;; Set the default variables if they have no name.
|
||||
(cl-macrolet ((setq-if-null (variable value)
|
||||
`(if (null ,variable)
|
||||
(setf ,variable ,value)))
|
||||
(getdir (variable fallback)
|
||||
`(expand-file-name "emacs/" (or (getenv ,variable) ,fallback))))
|
||||
(macrolet ((setq-if-null (variable value)
|
||||
`(if (null ,variable)
|
||||
(setf ,variable ,value)))
|
||||
(getdir (variable fallback)
|
||||
`(expand-file-name "emacs/" (or (getenv ,variable) ,fallback))))
|
||||
(setq-if-null user-emacs-config-directory (getdir "XDG_CONFIG_HOME" "~/.config/"))
|
||||
(setq-if-null user-emacs-data-directory (getdir "XDG_DATA_HOME" "~/.local/share/"))
|
||||
(setq-if-null user-emacs-cache-directory (getdir "XDG_CACHE_HOME" "~/.cache/"))
|
||||
@ -220,10 +219,12 @@ APPEND is passed directly to `add-to-path'."
|
||||
(setq-if-null user-documents-directory (or (xdg-user-dir "DOCUMENTS") "~/Documents")))
|
||||
|
||||
|
||||
;; Set the user-emacs-directory to user-emacs-data-directory.
|
||||
;(setf user-emacs-directory user-emacs-data-directory)
|
||||
|
||||
|
||||
;; Add the user lisp directory to path.
|
||||
(add-to-list 'load-path user-emacs-lisp-directory)
|
||||
|
||||
|
||||
(provide 'xdg-paths)
|
||||
|
||||
;;; xdg-paths.el ends here
|
||||
|
19
lisp/zim.el
Normal file
19
lisp/zim.el
Normal file
@ -0,0 +1,19 @@
|
||||
(defun zim-timestamp ()
|
||||
(with-temp-buffer
|
||||
(insert (format-time-string "%Y-%m-%dT%H:%M:%S%z"))
|
||||
(forward-char -2)
|
||||
(insert ":")
|
||||
(buffer-string)))
|
||||
|
||||
(defun insert-zim-timestamp ()
|
||||
(interactive)
|
||||
(insert (zim-timestamp)))
|
||||
|
||||
(defun insert-zim-header ()
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(insert
|
||||
(concat "Content-Type: text/x-zim-wiki\n"
|
||||
"Wiki-Format: zim 0.4\n"
|
||||
"Creation-Date: " (zim-timestamp) "\n\n"))))
|
@ -1,11 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: GObject H boilerplate
|
||||
# key: gobh
|
||||
# --
|
||||
# include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
$0
|
||||
|
||||
G_END_DECLS
|
@ -1,10 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: Protect with ifdef
|
||||
# key: defprot
|
||||
# --
|
||||
#ifndef ${1:name}
|
||||
# define $1
|
||||
|
||||
$0
|
||||
|
||||
#endif /* $1 */
|
@ -1,19 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: agpl-header
|
||||
# key: agpl
|
||||
# --
|
||||
# ${1:project_name}
|
||||
# Copyright (C) ${2:year} ${3:author_name}
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
@ -1,10 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: flask_sqlalchemy_model
|
||||
# key: model
|
||||
# --
|
||||
class ${1:name}(db.Model):
|
||||
__tablename__ = '${2:tablename}'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
||||
$0
|
@ -1,9 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: New unittest
|
||||
# key: testdef
|
||||
# --
|
||||
def test_${1:name}(self):
|
||||
"""${2:docstring}
|
||||
"""
|
||||
|
||||
$0self.assertTrue(False)
|
@ -1,14 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: Translatable Flask-SQLAlchemy model
|
||||
# key: tmodel
|
||||
# --
|
||||
class ${1:name}(Translatable, db.Model):
|
||||
__tablename__ = '${2:tablename}s'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
||||
|
||||
class $1Translation(translation_base($1)):
|
||||
__tablename__ = '$2_translations'
|
||||
|
||||
$0
|
@ -1,5 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# name: Viewport Meta tag
|
||||
# key: vp
|
||||
# --
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
Loading…
x
Reference in New Issue
Block a user