@ -0,0 +1,7 @@ | |||
;;; cli.el -*- lexical-binding: t; -*- | |||
(setq org-confirm-babel-evaluate nil) | |||
(defun doom-shut-up-a (orig-fn &rest args) | |||
(quiet! (apply orig-fn args))) | |||
(advice-add 'org-babel-execute-src-block :around #'doom-shut-up-a) |
@ -1,160 +1,454 @@ | |||
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*- | |||
;; Place your private configuration here! Remember, you do not need to run 'doom | |||
;; sync' after modifying this file! | |||
;; __ _______ _____ _____ | |||
;; \ \ / / ____| ____|_ _| | |||
;; \ V /| _| | _| | | | |||
;; | | | |___| |___ | | | |||
;; |_| |_____|_____| |_| | |||
;; Yeet's Doom Emacs configuration | |||
;; Some functionality uses this to identify you, e.g. GPG configuration, email | |||
;; clients, file templates and snippets. | |||
;; Global Configuration | |||
(setq user-full-name "Yigit Colakoglu" | |||
user-mail-address "yigit@yigitcolakoglu.com") | |||
user-mail-address "yigit@yigitcolakoglu.com") | |||
(add-to-list 'default-frame-alist | |||
'(ns-transparent-titlebar . t)) | |||
(add-to-list 'default-frame-alist | |||
'(ns-appearance . light)) | |||
(setq org-directory "~/Documents/org/") | |||
(setq org-journal-dir "~/Documents/org/journal/") | |||
(setq display-line-numbers-type 'relative) | |||
(setq twittering-allow-insecure-server-cert t) | |||
(setq +ivy-buffer-preview t) | |||
(global-auto-revert-mode t) | |||
(global-subword-mode 1) ; Iterate through CamelCase words | |||
(setq-default | |||
delete-by-moving-to-trash t ; Delete files to trash | |||
window-combination-resize t ; take new window space from all other windows (not just current) | |||
x-stretch-cursor t) ; Stretch cursor to the glyph width | |||
(setq undo-limit 80000000 ; Raise undo-limit to 80Mb | |||
evil-want-fine-undo t ; By default while in insert all changes are one big blob. Be more granular | |||
auto-save-default t ; Nobody likes to loose work, I certainly don't | |||
truncate-string-ellipsis "…") ; Unicode ellispis are nicer than "...", and also save /precious/ space | |||
;; Experimental, delete if you don't like it | |||
(setq evil-vsplit-window-right t | |||
evil-split-window-below t) | |||
(require 'bison-mode) | |||
(after! bison-mode-hook | |||
(setq imenu-create-index-function | |||
(lambda () | |||
(let ((end)) | |||
(beginning-of-buffer) | |||
(re-search-forward "^%%") | |||
(forward-line 1) | |||
(setq end (save-excursion (re-search-forward "^%%") (point))) | |||
(loop while (re-search-forward "^\\([a-z].*?\\)\\s-*\n?\\s-*:" end t) | |||
collect (cons (match-string 1) (point))))))) | |||
(defadvice! prompt-for-buffer (&rest _) | |||
:after '(evil-window-split evil-window-vsplit) | |||
(+ivy/switch-buffer)) | |||
(use-package! ox-hugo | |||
:after ox | |||
) | |||
(use-package! elfeed-org | |||
:after elfeed | |||
:config | |||
(elfeed-org) | |||
(setq rmh-elfeed-org-files (list "~/.doom.d/elfeed.org")) | |||
) | |||
(use-package! deft | |||
:hook deft-mode-hook | |||
:init | |||
(setq deft-directory org-directory) | |||
(setq deft-recursive t) | |||
) | |||
(use-package! hl-todo | |||
:hook (prog-mode . hl-todo-mode) | |||
:config | |||
(setq hl-todo-keyword-faces | |||
`( | |||
("PROJ" . ,(face-foreground 'error)) | |||
("SOMEDAY" . ,(face-foreground 'warning)) | |||
("TODO" . ,(face-foreground 'warning)) | |||
("PROG" . ,(face-foreground 'error)) | |||
("NEXT" . ,(face-foreground 'error)) | |||
("WAIT" . ,(face-foreground 'warning)) | |||
("CANCEL" . ,(face-foreground 'error)) | |||
("DELEGATED" . ,(face-foreground 'error)) | |||
("IDEA" . ,(face-foreground 'warning)) | |||
("GOAL" . ,(face-foreground 'warning)) | |||
("DUD" . ,(face-foreground 'error)) | |||
("RD" . ,(face-foreground 'warning)) | |||
("RDING" . ,(face-foreground 'warning)) | |||
("RDNOTE" . ,(face-foreground 'warning)) | |||
("TMPDROP" . ,(face-foreground 'warning)) | |||
("DROP" . ,(face-foreground 'error)) | |||
("FNSHED" . ,(face-foreground 'success)) | |||
("DONE" . ,(face-foreground 'success))))) | |||
(use-package! engrave-faces-latex | |||
:after ox-latex) | |||
(use-package! org-ol-tree | |||
:commands org-ol-tree) | |||
(use-package! org-chef | |||
:commands (org-chef-insert-recipe org-chef-get-recipe-from-url)) | |||
(use-package! org-pretty-table | |||
:commands (org-pretty-table-mode global-org-pretty-table-mode)) | |||
(use-package! aas :commands aas-mode) | |||
(use-package! laas | |||
:hook (LaTeX-mode . laas-mode) | |||
:config | |||
(defun laas-tex-fold-maybe () | |||
(unless (equal "/" aas-transient-snippet-key) | |||
(+latex-fold-last-macro-a))) | |||
(add-hook 'aas-post-snippet-expand-hook #'laas-tex-fold-maybe)) | |||
(use-package! calfw-org | |||
:after calfw) | |||
(use-package! org-agenda | |||
:defer | |||
:init | |||
(setq org-agenda-files (list | |||
(concat org-directory "projects.org") | |||
(concat org-directory "monthly_habits.org") | |||
(concat org-directory "quarterly_habits.org") | |||
(concat org-directory "personal.org") | |||
(concat org-directory "taxes.org") | |||
(concat org-directory "birthdays_and_important_days.org") | |||
(concat org-directory "reading_list.org") | |||
(concat org-directory "school.org") | |||
(concat org-directory "daily_habits.org") | |||
(concat org-directory "weekly_habits.org") | |||
(concat org-directory "reflections/2021_refl.org") | |||
(concat org-directory "someday.org") | |||
(concat org-directory "projects/2021/") | |||
org-journal-dir)) | |||
:config | |||
(setq org-habit-show-habits-only-for-today t) | |||
;; Org Agenda Files | |||
;; org agenda | |||
(setq org-agenda-time-grid | |||
(quote | |||
((daily today remove-match) | |||
(700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300) | |||
"......" "----------------"))) | |||
) | |||
(use-package! org-super-agenda | |||
:after org-agenda | |||
:init | |||
;; for some reason org-agenda evil bindings were being weird with j and k | |||
(map! :map org-agenda-keymap "j" #'org-agenda-next-line) | |||
(map! :map org-agenda-mode-map "j" #'org-agenda-next-line) | |||
(map! :map org-super-agenda-header-map "j" #'org-agenda-next-line) | |||
(map! :map org-agenda-keymap "k" #'org-agenda-previous-line) | |||
(map! :map org-agenda-mode-map "k" #'org-agenda-previous-line) | |||
(map! :map org-super-agenda-header-map "k" #'org-agenda-previous-line) | |||
(map! :map org-super-agenda-header-map "k" #'org-agenda-previous-line) | |||
(map! :map org-super-agenda-header-map "k" #'org-agenda-previous-line) | |||
(setq org-agenda-custom-commands '( | |||
("r" "Main View" | |||
((agenda "" ((org-agenda-span 'day) | |||
(org-agenda-start-day "+0d") | |||
(org-agenda-overriding-header "") | |||
(org-super-agenda-groups | |||
'((:name "Today" | |||
:time-grid t | |||
:date today | |||
:order 1 | |||
:scheduled today | |||
:todo "TODAY"))))) | |||
(alltodo "" ((org-agenda-overriding-header "") | |||
(org-super-agenda-groups | |||
'( | |||
(:discard (:habit)) | |||
(:todo "PROJ") | |||
(:todo "PROG") | |||
(:todo "NEXT") | |||
(:todo "WAIT") | |||
(:todo "RD") | |||
(:todo "RDING") | |||
(:todo "RDNOTE") | |||
(:name "Important" :priority "A") | |||
(:todo "TODO") | |||
(:todo "GOAL") | |||
(:discard (:todo "IDEA")) | |||
(:discard (:todo "RD")) | |||
(:discard (:todo "TMPDROP")) | |||
(:discard (:todo "SOMEDAY")) | |||
)))))) | |||
("w" "Someday and Idea" | |||
((alltodo "" ((org-agenda-overriding-header "") | |||
(org-super-agenda-groups | |||
'( | |||
(:todo "IDEA") | |||
(:todo "SOMEDAY") | |||
(:discard (:todo "PROJ")) | |||
(:discard (:todo "PROG")) | |||
(:discard (:todo "NEXT")) | |||
(:discard (:todo "WAIT")) | |||
(:discard (:todo "RDNOTE")) | |||
(:discard (:todo "RD")) | |||
(:discard (:todo "RDING")) | |||
(:discard (:todo "TODO")) | |||
(:discard (:todo "GOAL")) | |||
) | |||
))))))) | |||
:config | |||
(org-super-agenda-mode)) | |||
;; Org Roam | |||
(use-package! org-roam | |||
:commands (org-roam-insert org-roam-find-file org-roam) | |||
:init | |||
(setq org-roam-directory (concat org-directory "roam")) | |||
(setq org-roam-buffer-width 0.2) | |||
(map! :leader | |||
:prefix "n" | |||
:desc "Org-Roam-Insert" "i" #'org-roam-insert | |||
:desc "Org-Roam-Find" "/" #'org-roam-find-file | |||
:desc "Org-Roam-Buffer" "r" #'org-roam) | |||
) | |||
;; Attempt to remove lag | |||
(setq key-chord-two-keys-delay 0.7) | |||
(add-hook! 'org-mode-hook (company-mode -1)) | |||
(add-hook! 'org-capture-mode-hook (company-mode -1)) | |||
(after! org (load! "org-conf.el")) | |||
(setq baby-blue '("#d2ecff" "#d2ecff" "brightblue")) | |||
;; Better window management | |||
(map! :map evil-window-map | |||
"SPC" #'rotate-layout | |||
;; Navigation | |||
"<left>" #'evil-window-left | |||
"<down>" #'evil-window-down | |||
"<up>" #'evil-window-up | |||
"<right>" #'evil-window-right | |||
;; Swapping windows | |||
"C-<left>" #'+evil/window-move-left | |||
"C-<down>" #'+evil/window-move-down | |||
"C-<up>" #'+evil/window-move-up | |||
"C-<right>" #'+evil/window-move-right) | |||
(after! company | |||
(setq company-idle-delay 0.2 | |||
company-minimum-prefix-length 2)) | |||
(after! evil-escape (evil-escape-mode -1)) | |||
(after! evil (setq evil-ex-substitute-global t)) ; I like my s/../.. to by global by default | |||
(setq emojify-emoji-set "twemoji-v2") | |||
(setq-default history-length 1000) | |||
(setq-default prescient-history-length 1000) | |||
(set-company-backend! | |||
'(text-mode | |||
markdown-mode | |||
gfm-mode) | |||
'(:seperate | |||
company-ispell | |||
company-files | |||
company-yasnippet)) | |||
(setq | |||
doom-theme 'doom-challenger-deep | |||
doom-font (font-spec :family "CaskaydiaCove Nerd Font Mono" :size 16 :weight 'regular) | |||
default-directory "~" | |||
dart-format-on-save t | |||
web-mode-markup-indent-offset 2 | |||
web-mode-code-indent-offset 2 | |||
web-mode-css-indent-offset 2 | |||
mac-command-modifier 'meta | |||
js-indent-level 2 | |||
typescript-indent-level 2 | |||
json-reformat:indent-width 2 | |||
prettier-js-args '("--single-quote") | |||
projectile-project-search-path '("~/Projects/") | |||
dired-dwim-target t | |||
org-ellipsis " ▾ " | |||
org-bullets-bullet-list '("·") | |||
org-tags-column -80 | |||
org-agenda-files (ignore-errors (directory-files +org-dir t "\\.org$" t)) | |||
org-log-done 'time | |||
css-indent-offset 2 | |||
org-refile-targets (quote ((nil :maxlevel . 1))) | |||
org-capture-templates '(("x" "Note" entry | |||
(file+olp+datetree "journal.org") | |||
"**** [ ] %U %?" :prepend t :kill-buffer t) | |||
("t" "Task" entry | |||
(file+headline "tasks.org" "Inbox") | |||
"* [ ] %?\n%i" :prepend t :kill-buffer t)) | |||
+doom-dashboard-banner-file (expand-file-name "logo.png" doom-private-dir) | |||
+org-capture-todo-file "tasks.org" | |||
org-super-agenda-groups '((:name "Today" | |||
:time-grid t | |||
:scheduled today) | |||
(:name "Due today" | |||
:deadline today) | |||
(:name "Important" | |||
:priority "A") | |||
(:name "Overdue" | |||
:deadline past) | |||
(:name "Due soon" | |||
:deadline future) | |||
(:name "Big Outcomes" | |||
:tag "bo"))) | |||
(add-hook! reason-mode | |||
(add-hook 'before-save-hook #'refmt-before-save nil t)) | |||
(add-hook! | |||
js2-mode 'prettier-js-mode | |||
(add-hook 'before-save-hook #'refmt-before-save nil t)) | |||
default-directory "~" | |||
web-mode-markup-indent-offset 4 | |||
ispell-dictionary "en-custom" | |||
web-mode-code-indent-offset 4 | |||
web-mode-css-indent-offset 4 | |||
js-indent-level 4 | |||
json-reformat:indent-width 4 | |||
prettier-js-args '("--single-quote") | |||
projectile-project-search-path '("~/Projects/") | |||
dired-dwim-target t | |||
nand-hdl-directory "~/Projects/nand2tetris" | |||
css-indent-offset 2) | |||
(setq auth-sources | |||
'((:source "~/.config/emacs/.authinfo.gpg"))) | |||
(defun insert-current-date () (interactive) | |||
(insert (shell-command-to-string "echo -n $(date +%Y-%m-%d)"))) | |||
(insert (shell-command-to-string "echo -n $(date +%Y-%m-%d)"))) | |||
;; We expect the encoding to be LF UTF-8, so only show the modeline when this is not the case | |||
(defun doom-modeline-conditional-buffer-encoding () | |||
(setq-local doom-modeline-buffer-encoding | |||
(unless (and (memq (plist-get (coding-system-plist buffer-file-coding-system) :category) | |||
'(coding-category-undecided coding-category-utf-8)) | |||
(not (memq (coding-system-eol-type buffer-file-coding-system) '(1 2)))) | |||
t))) | |||
(add-hook 'after-change-major-mode-hook #'doom-modeline-conditional-buffer-encoding) | |||
(map! :ne "M-/" #'comment-or-uncomment-region) | |||
(map! :ne "SPC / r" #'deadgrep) | |||
(map! :ne "SPC n b" #'org-brain-visualize) | |||
(map! :ne "SPC i d" #'insert-current-date) | |||
;; (def-package! parinfer ; to configure it | |||
;; :bind (("C-," . parinfer-toggle-mode) | |||
;; ("<tab>" . parinfer-smart-tab:dwim-right) | |||
;; ("S-<tab>" . parinfer-smart-tab:dwim-left)) | |||
;; :hook ((clojure-mode emacs-lisp-mode common-lisp-mode lisp-mode) . parinfer-mode) | |||
;; :config (setq parinfer-extensions '(defaults pretty-parens evil paredit))) | |||
(after! org | |||
(set-face-attribute 'org-link nil | |||
:weight 'normal | |||
:background nil) | |||
(set-face-attribute 'org-code nil | |||
:foreground "#a9a1e1" | |||
:background nil) | |||
(set-face-attribute 'org-date nil | |||
:foreground "#5B6268" | |||
:background nil) | |||
(set-face-attribute 'org-level-1 nil | |||
:foreground "steelblue2" | |||
:background nil | |||
:height 1.2 | |||
:weight 'normal) | |||
(set-face-attribute 'org-level-2 nil | |||
:foreground "slategray2" | |||
:background nil | |||
:height 1.0 | |||
:weight 'normal) | |||
(set-face-attribute 'org-level-3 nil | |||
:foreground "SkyBlue2" | |||
:background nil | |||
:height 1.0 | |||
:weight 'normal) | |||
(set-face-attribute 'org-level-4 nil | |||
:foreground "DodgerBlue2" | |||
:background nil | |||
:height 1.0 | |||
:weight 'normal) | |||
(set-face-attribute 'org-level-5 nil | |||
:weight 'normal) | |||
(set-face-attribute 'org-level-6 nil | |||
:weight 'normal) | |||
(set-face-attribute 'org-document-title nil | |||
:foreground "SlateGray1" | |||
:background nil | |||
:height 1.75 | |||
:weight 'bold) | |||
(setq org-fancy-priorities-list '("⚡" "⬆" "⬇" "☕"))) | |||
(after! web-mode | |||
(add-to-list 'auto-mode-alist '("\\.njk\\'" . web-mode))) | |||
(defun +data-hideshow-forward-sexp (arg) | |||
(let ((start (current-indentation))) | |||
(forward-line) | |||
(unless (= start (current-indentation)) | |||
(require 'evil-indent-plus) | |||
(let ((range (evil-indent-plus--same-indent-range))) | |||
(goto-char (cadr range)) | |||
(end-of-line))))) | |||
(add-to-list 'hs-special-modes-alist '(yaml-mode "\\s-*\\_<\\(?:[^:]+\\)\\_>" "" "#" +data-hideshow-forward-sexp nil)) | |||
(setq org-directory "~/Documents/org/") | |||
;; zoom in/out like we do everywhere else. | |||
(global-set-key (kbd "C-=") 'text-scale-increase) | |||
(global-set-key (kbd "C--") 'text-scale-decrease) | |||
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease) | |||
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase) | |||
(setq +magit-hub-features t) | |||
(setq calc-angle-mode 'rad ; radians are rad | |||
calc-symbolic-mode t) ; keeps expressions like \sqrt{2} irrational for as long as possible | |||
(use-package! calctex | |||
:commands calctex-mode | |||
:init | |||
(add-hook 'calc-mode-hook #'calctex-mode) | |||
:config | |||
(setq calctex-additional-latex-packages " | |||
\\usepackage[usenames]{xcolor} | |||
\\usepackage{soul} | |||
\\usepackage{adjustbox} | |||
\\usepackage{amsmath} | |||
\\usepackage{amssymb} | |||
\\usepackage{siunitx} | |||
\\usepackage{cancel} | |||
\\usepackage{mathtools} | |||
\\usepackage{mathalpha} | |||
\\usepackage{xparse} | |||
\\usepackage{arevmath}" | |||
calctex-additional-latex-macros | |||
(concat calctex-additional-latex-macros | |||
"\n\\let\\evalto\\Rightarrow")) | |||
(defadvice! no-messaging-a (orig-fn &rest args) | |||
:around #'calctex-default-dispatching-render-process | |||
(let ((inhibit-message t) message-log-max) | |||
(apply orig-fn args))) | |||
;; Fix hardcoded dvichop path (whyyyyyyy) | |||
(let ((vendor-folder (concat (file-truename doom-local-dir) | |||
"straight/" | |||
(format "build-%s" emacs-version) | |||
"/calctex/vendor/"))) | |||
(setq calctex-dvichop-sty (concat vendor-folder "texd/dvichop") | |||
calctex-dvichop-bin (concat vendor-folder "texd/dvichop"))) | |||
(unless (file-exists-p calctex-dvichop-bin) | |||
(message "CalcTeX: Building dvichop binary") | |||
(let ((default-directory (file-name-directory calctex-dvichop-bin))) | |||
(call-process "make" nil nil nil)))) | |||
(defun greedily-do-daemon-setup () | |||
(require 'org) | |||
(when (require 'elfeed nil t) | |||
(run-at-time nil (* 8 60 60) #'elfeed-update))) | |||
;; Open new clients in the dashboard | |||
(when (daemonp) | |||
(add-hook 'emacs-startup-hook #'greedily-do-daemon-setup) | |||
(add-hook! 'server-after-make-frame-hook (switch-to-buffer +doom-dashboard-name))) | |||
(set-popup-rule! "^\\*Org Agenda" :side 'bottom :size 0.90 :select t :ttl nil) | |||
(set-popup-rule! "^CAPTURE.*\\.org$" :side 'bottom :size 0.90 :select t :ttl nil) | |||
(set-popup-rule! "^\\*org-brain" :side 'right :size 1.00 :select t :ttl nil) | |||
(defun my-open-calendar () | |||
(sp-local-pair | |||
'(org-mode) | |||
"<<" ">>" | |||
:actions '(insert)) | |||
(setq +zen-text-scale 0.8) | |||
(use-package! lexic | |||
:commands lexic-search lexic-list-dictionary | |||
:config | |||
(map! :map lexic-mode-map | |||
:n "q" #'lexic-return-from-lexic | |||
:nv "RET" #'lexic-search-word-at-point | |||
:n "a" #'outline-show-all | |||
:n "h" (cmd! (outline-hide-sublevels 3)) | |||
:n "o" #'lexic-toggle-entry | |||
:n "n" #'lexic-next-entry | |||
:n "N" (cmd! (lexic-next-entry t)) | |||
:n "p" #'lexic-previous-entry | |||
:n "P" (cmd! (lexic-previous-entry t)) | |||
:n "E" (cmd! (lexic-return-from-lexic) ; expand | |||
(switch-to-buffer (lexic-get-buffer))) | |||
:n "M" (cmd! (lexic-return-from-lexic) ; minimise | |||
(lexic-goto-lexic)) | |||
:n "C-p" #'lexic-search-history-backwards | |||
:n "C-n" #'lexic-search-history-forwards | |||
:n "/" (cmd! (call-interactively #'lexic-search)))) | |||
(defadvice! +lookup/dictionary-definition-lexic (identifier &optional arg) | |||
:override #'+lookup/dictionary-definition | |||
(interactive | |||
(list (or (doom-thing-at-point-or-region 'word) | |||
(read-string "Look up in dictionary: ")) | |||
current-prefix-arg)) | |||
(lexic-search identifier nil nil t)) | |||
;; Hooks | |||
(add-hook 'nand-hdl-mode-hook 'yas-minor-mode) | |||
(defun after-org-mode-load () | |||
(interactive) | |||
(cfw:open-calendar-buffer | |||
:contents-sources | |||
(list | |||
(cfw:org-create-source "Green") ; org-agenda source | |||
))) | |||
(setq olivetti-body-width 0.8) | |||
(olivetti-mode) | |||
) | |||
(add-hook! 'org-mode-hook 'after-org-mode-load) | |||
;; Auto-Insert | |||
(autoload 'yas-expand-snippet "yasnippet") | |||
(defun my-autoinsert-yas-expand() | |||
"Replace text in yasnippet template." | |||
(yas-expand-snippet (buffer-string) (point-min) (point-max))) | |||
(setq-default auto-insert-directory "~/.config/doom/templates") | |||
(auto-insert-mode 1) ;;; Adds hook to find-files-hook | |||
(setq-default auto-insert-query nil) ;;; If you don't want to be prompted before insertion | |||
(define-auto-insert "\\.el$" ["template.el" my-autoinsert-yas-expand]) | |||
(define-auto-insert "\\.c$" ["template.c" my-autoinsert-yas-expand]) | |||
(define-auto-insert "\\.cpp$" ["template.cpp" my-autoinsert-yas-expand]) | |||
(define-auto-insert "\\.h$" ["template.h" my-autoinsert-yas-expand]) | |||
(define-auto-insert "\\.cc$" ["template.cpp" my-autoinsert-yas-expand]) | |||
(define-auto-insert "\\.tex$" ["template.tex" my-autoinsert-yas-expand]) | |||
(define-auto-insert "\\.org$" ["template.org" my-autoinsert-yas-expand]) | |||
(define-auto-insert "\\.py$" ["template.py" my-autoinsert-yas-expand]) | |||
(define-auto-insert "\\.java$" ["template.java" my-autoinsert-yas-expand]) | |||
(define-auto-insert "\\.sh$" ["template.sh" my-autoinsert-yas-expand]) | |||
(define-auto-insert "\\.html$" ["template.html" my-autoinsert-yas-expand]) | |||
(setq yas-snippet-dirs | |||
'("~/.config/doom/snippets")) | |||
;; Appearance | |||
(delq! t custom-theme-load-path) ;; Don't prompt on startup | |||
(setq doom-theme 'doom-material-ocean) | |||
(setq | |||
doom-big-font (font-spec :family "CasaydiaCove Nerd Font" :size 22) | |||
doom-font (font-spec :family "CaskaydiaCove Nerd Font" :size 16) | |||
doom-variable-pitch-font (font-spec :family "Overpass" :size 16) | |||
doom-unicode-font (font-spec :family "JuliaMono") | |||
doom-serif-font (font-spec :family "IBM Plex Mono" :weight 'light)) | |||
(setq +doom-dashboard-banner-file (expand-file-name "logo.png" doom-private-dir)) | |||
@ -0,0 +1,46 @@ | |||
(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. | |||
'(ansi-color-names-vector | |||
["#1E1C31" "#FF8080" "#95FFA4" "#FFE9AA" "#91DDFF" "#C991E1" "#AAFFE4" "#CBE3E7"]) | |||
'(custom-safe-themes | |||
'("01d5e0971bfe4b70669ba03f632c68ac7e5b9e0bc5eaf760a780d88ca271dae2" default)) | |||
'(fci-rule-color "#858FA5") | |||
'(jdee-db-active-breakpoint-face-colors (cons "#100E23" "#906CFF")) | |||
'(jdee-db-requested-breakpoint-face-colors (cons "#100E23" "#95FFA4")) | |||
'(jdee-db-spec-breakpoint-face-colors (cons "#100E23" "#565575")) | |||
'(objed-cursor-color "#FF8080") | |||
'(pdf-view-midnight-colors (cons "#CBE3E7" "#1E1C31")) | |||
'(rustic-ansi-faces | |||
["#1E1C31" "#FF8080" "#95FFA4" "#FFE9AA" "#91DDFF" "#C991E1" "#AAFFE4" "#CBE3E7"]) | |||
'(vc-annotate-background "#1E1C31") | |||
'(vc-annotate-color-map | |||
(list | |||
(cons 20 "#95FFA4") | |||
(cons 40 "#b8f7a6") | |||
(cons 60 "#dbf0a8") | |||
(cons 80 "#FFE9AA") | |||
(cons 100 "#ffd799") | |||
(cons 120 "#ffc488") | |||
(cons 140 "#FFB378") | |||
(cons 160 "#eda79b") | |||
(cons 180 "#db9cbd") | |||
(cons 200 "#C991E1") | |||
(cons 220 "#db8bc0") | |||
(cons 240 "#ed85a0") | |||
(cons 260 "#FF8080") | |||
(cons 280 "#d4757d") | |||
(cons 300 "#aa6a7a") | |||
(cons 320 "#805f77") | |||
(cons 340 "#858FA5") | |||
(cons 360 "#858FA5"))) | |||
'(vc-annotate-very-old-color nil)) | |||
(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. | |||
) | |||
(put 'projectile-ripgrep 'disabled nil) |
@ -0,0 +1,913 @@ | |||
;;; bison-mode.el --- Major mode for editing bison, yacc and lex files. | |||
;; Copyright (C) 1998 Eric Beuscher | |||
;; | |||
;; Author: Eric Beuscher <beuscher@eecs.tulane.edu> | |||
;; Created: 2 Feb 1998 | |||
;; Version: 0.2 | |||
;; Keywords: bison-mode, yacc-mode | |||
;; 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 2 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. | |||
;;; Commentary: | |||
;;;; I wrote this since I saw one mode for yacc files out there roaming the | |||
;;;; world. I was daunted by the fact the it was written in 1990, and Emacs | |||
;;;; has evolved so much since then (this I assume based on its evolution since | |||
;;;; i started using it). So I figured if i wanted one, I should make it | |||
;;;; myself. Please excuse idiosyncrasies, as this was my first major mode | |||
;;;; of this kind. The indentation code may be a bit weird, I am not sure, | |||
;;;; it was my first go at doing Emacs indentation, so I look at how other | |||
;;;; modes did it, but then basically did what I thought was right | |||
;;;; I hope this is useful to other hackers, and happy Bison/Yacc hacking | |||
;;;; If you have ideas/suggestions/problems with this code, I can be reached at | |||
;;;; beuscher@eecs.tulane.edu | |||
;;;; Eric --- Sat Mar 7 1:40:20 CDT 1998 | |||
;;;; Bison Sections: | |||
;;;; there are five sections to a bison file (if you include the area above the | |||
;;;; C declarations section. most everything in this file either does | |||
;;;; actions based on which section you are deemed to be in, or based on an | |||
;;;; assumption that the function will only be called from certain sections. | |||
;;;; the function `bison--section-p' is the section parser | |||
;;;; Indentation: | |||
;;;; indentations are done based on the section of code you are in. there is | |||
;;;; a procedure `bison--within-braced-c-expression-p' that checks for being in | |||
;;;; C code. if you are within c-code, indentations should occur based on | |||
;;;; how you have your C indentation set up. i am pretty sure this is the | |||
;;;; case. | |||
;;;; there are four variables, which control bison indentation within either | |||
;;;; the bison declarations section or the bison grammar section | |||
;;;; `bison-rule-separator-column' | |||
;;;; `bison-rule-separator-column' | |||
;;;; `bison-decl-type-column' | |||
;;;; `bison-decl-token-column' | |||
;;;; flaw: indentation works on a per-line basis, unless within braced C sexp, | |||
;;;; i should fix this someday | |||
;;;; and to make matters worse, i never took out c-indent-region, so that is | |||
;;;; still the state of the `indent-region-function' variable | |||
;;;; Electricity: | |||
;;;; by default, there are electric -colon, -pipe, -open-brace, -close-brace, | |||
;;;; -semicolon, -percent, -less-than, -greater-than | |||
;;;; the indentation caused by these work closely with the 4 indentation | |||
;;;; variables mentioned above. | |||
;;;; any of these can be turned off individually by setting the appropriate | |||
;;;; `bison-electric-...' variable. or all of them can be turned off by | |||
;;;; setting `bison-all-electricity-off' | |||
;;;; todo: should make available a way to use C-electricity if in C sexps | |||
;;; Code: | |||
(require 'cc-mode) | |||
;;;###autoload | |||
(add-to-list 'auto-mode-alist '("\\.y\\'" . bison-mode)) | |||
;;;###autoload | |||
(add-to-list 'auto-mode-alist '("\\.l\\'" . flex-mode)) | |||
;;;###autoload | |||
(add-to-list 'auto-mode-alist '("\\.jison\\'" . jison-mode)) | |||
;; *************** internal vars *************** | |||
(defvar bison--declarers '("%union" "%token" "%type" | |||
"%left" "%right" "%nonassoc") | |||
"commands which can declare a token or state type") | |||
(defvar bison--word-constituent-re "\\(\\sw\\|_\\)") | |||
(defvar bison--production-re | |||
(concat "^" bison--word-constituent-re "+:")) | |||
(defvar bison--pre-c-decls-section 0 | |||
"section before c-declarations-section, if that section exists") | |||
(defvar bison--c-decls-section 1 | |||
"section denoted by %{ and $} for c-declarations at the top of a bison file") | |||
(defvar bison--bison-decls-section 2 | |||
"section before the rules section") | |||
(defvar bison--grammar-rules-section 3 | |||
"section delimited by %%'s where productions and rules are enumerated") | |||
(defvar bison--c-code-section 4 | |||
"section after the second %% where c-code can be placed") | |||
(defvar bison--c-decls-section-opener "%{") | |||
(defvar bison--c-decls-section-closer "%}") | |||
(defvar bison--grammar-rules-section-delimeter "%%") | |||
;; *************** user-definable vars *************** | |||
(defvar bison-rule-separator-column 8 | |||
"column for rule and production separators \"|\" and \";\"") | |||
(defvar bison-rule-enumeration-column 16 | |||
"column for beginning enumeration of a production's rules") | |||
(defvar bison-decl-type-column 8 | |||
"columnn in which tokens' and states' types should be when declared") | |||
(defvar bison-decl-token-column 24 | |||
"column in which tokens and states are listed when declared, | |||
as with %token, %type, ...") | |||
(defvar bison-all-electricity-off nil | |||
"non-nil means all electric keys will be disabled, | |||
nil means that a bison-electric-* key will be on or off based on the individual | |||
key's electric variable") | |||
;;; i know lisp has the dual name spaces, but i find it more aesthetically | |||
;;; pleasing to not take advantage of that | |||
(defvar bison-electric-colon-v t | |||
"non-nil means use an electric colon") | |||
(defvar bison-electric-pipe-v t | |||
"non-nil means use an electric pipe") | |||
(defvar bison-electric-open-brace-v t | |||
"non-nil means use an electric open-brace") | |||
(defvar bison-electric-close-brace-v t | |||
"non-nil means use an electric close-brace") | |||
(defvar bison-electric-semicolon-v t | |||
"non-nil means use an electric semicolon") | |||
(defvar bison-electric-percent-v t | |||
"non-nil means use an electric percent") | |||
(defvar bison-electric-less-than-v t | |||
"non-nil means use an electric less-than") | |||
(defvar bison-electric-greater-than-v t | |||
"non-nil means use an electric greater-than") | |||
(defconst bison-font-lock-keywords | |||
(append | |||
(list | |||
(cons (concat "^\\(" (regexp-opt bison--declarers) "\\)") | |||
'(1 font-lock-keyword-face)) | |||
) | |||
c-font-lock-keywords) | |||
"Default expressions to highlight in Bison mode") | |||
;; *************** utilities *************** | |||
(defun just-no-space () | |||
"Delete all spaces and tabs around point, leaving no spaces." | |||
(interactive "*") | |||
(skip-chars-backward " \t") | |||
(delete-region (point) (progn (skip-chars-forward " \t") (point))) | |||
t) | |||
(defun previous-white-space-p () | |||
"return t if there is whitespace between the beginning of the line and the | |||
current (point)" | |||
(save-excursion | |||
(let ((current-point (point))) | |||
(beginning-of-line) | |||
(if (re-search-forward "\\s " current-point t) | |||
t | |||
nil)))) | |||
(defun previous-non-ws-p () | |||
"return t if there are non-whitespace characters between beginning of line | |||
and \(point\)" | |||
(save-excursion | |||
(let ((current-point (point))) | |||
(beginning-of-line) | |||
(re-search-forward "[^ \t]" current-point t) | |||
))) | |||
(defun following-non-ws-p () | |||
"return t if there are non-whitespace characters on the line" | |||
(save-excursion | |||
(let ((current-point (point))) | |||
(end-of-line) | |||
(re-search-backward "[^ \t]+" current-point t) | |||
))) | |||
(defun line-of-whitespace-p () | |||
"return t if the line consists of nothiing but whitespace, nil otherwise" | |||
(save-excursion | |||
(let ((eol (progn (end-of-line) (point)))) | |||
(beginning-of-line) ;; should already be there anyway | |||
(not (re-search-forward "[^ \t\n]" eol t))))) | |||
;; *************** bison-mode *************** | |||
;;;###autoload | |||
(define-derived-mode bison-mode c-mode "Bison" | |||
"Major mode for editing bison/yacc files." | |||
;; try to set the indentation correctly | |||
(setq c-basic-offset 4) | |||
(c-set-offset 'knr-argdecl-intro 0) | |||
;; remove auto and hungry anything | |||
(c-toggle-auto-hungry-state -1) | |||
(c-toggle-auto-newline -1) | |||
(c-toggle-hungry-state -1) | |||
(use-local-map bison-mode-map) | |||
(define-key bison-mode-map ":" 'bison-electric-colon) | |||
(define-key bison-mode-map "|" 'bison-electric-pipe) | |||
(define-key bison-mode-map "{" 'bison-electric-open-brace) | |||
(define-key bison-mode-map "}" 'bison-electric-close-brace) | |||
(define-key bison-mode-map ";" 'bison-electric-semicolon) | |||
(define-key bison-mode-map "%" 'bison-electric-percent) | |||
(define-key bison-mode-map "<" 'bison-electric-less-than) | |||
(define-key bison-mode-map ">" 'bison-electric-greater-than) | |||
(define-key bison-mode-map [tab] 'bison-indent-line) | |||
(make-local-variable 'indent-line-function) | |||
(setq indent-line-function 'bison-indent-new-line) | |||
(make-local-variable 'comment-start) | |||
(make-local-variable 'comment-end) | |||
(setq comment-start "/*" | |||
comment-end "*/") | |||
(make-local-variable 'font-lock-keywords) | |||
(setq font-lock-keywords nil) | |||
(set (make-local-variable 'font-lock-defaults) '(bison-font-lock-keywords))) | |||
;; *************** section parsers *************** | |||
(defun bison--section-p () | |||
"Return the section that user is currently in" | |||
(save-excursion | |||
(let ((bound (point))) | |||
(goto-char (point-min)) | |||
(bison--section-p-helper bound)))) | |||
(defun bison--section-p-helper (bound) | |||
(if (re-search-forward | |||
(concat "^" bison--c-decls-section-opener) | |||
bound t) | |||
(if (re-search-forward | |||
(concat "^" bison--c-decls-section-closer) | |||
bound t) | |||
(if (re-search-forward | |||
(concat "^" bison--grammar-rules-section-delimeter) | |||
bound t) | |||
(if (re-search-forward | |||
(concat "^" bison--grammar-rules-section-delimeter) | |||
bound t) | |||
bison--c-code-section | |||
bison--grammar-rules-section) | |||
bison--bison-decls-section) | |||
bison--c-decls-section) | |||
(if (re-search-forward | |||
(concat "^" bison--grammar-rules-section-delimeter) | |||
bound t) | |||
(if (re-search-forward | |||
(concat "^" bison--grammar-rules-section-delimeter) | |||
bound t) | |||
bison--c-code-section | |||
bison--grammar-rules-section) | |||
(if (re-search-forward | |||
(concat "^" bison--c-decls-section-opener) | |||
nil t) | |||
bison--pre-c-decls-section | |||
(if (re-search-forward | |||
(concat "^" bison--grammar-rules-section-delimeter) | |||
nil t) | |||
bison--bison-decls-section | |||
bison--pre-c-decls-section))))) | |||
;; *************** syntax parsers *************** | |||
(defun bison--production-p () | |||
"return t if the \(point\) rests immediately after a production" | |||
(save-excursion | |||
(let ((current-point (point))) | |||
(beginning-of-line) | |||
(let ((position (re-search-forward | |||
bison--production-re current-point t))) | |||
(and position | |||
(not (previous-white-space-p)) | |||
(= position current-point)))))) | |||
(defun bison--find-production-opener () | |||
"return and goto the point of the nearest production opener above \(point\)" | |||
(re-search-backward bison--production-re nil t)) | |||
(defun bison--find-next-production () | |||
"return the position of the beginning of the next production, | |||
or nil if there isnt one" | |||
(save-excursion | |||
(if (re-search-forward bison--production-re nil t) | |||
(progn | |||
(beginning-of-line) | |||
(point)) | |||
nil))) | |||
(defun bison--find-grammar-end () | |||
"return the position of the end of the grammar rules (assuming we are within | |||
the grammar rules section), or nil if there isnt one" | |||
(save-excursion | |||
(if (re-search-forward | |||
(concat "^" bison--grammar-rules-section-delimeter) | |||
nil t) | |||
(progn | |||
(beginning-of-line) | |||
(point)) | |||
nil))) | |||
(defun bison--find-grammar-begin () | |||
"return the position of the beginning of the grammar rules (assuming we are | |||
within the grammar rules section), or nil if there isnt one" | |||
(save-excursion | |||
(if (re-search-backward | |||
(concat "^" bison--grammar-rules-section-delimeter) | |||
nil t) | |||
(point) | |||
nil))) | |||
(defun bison--within-started-production-p () | |||
"is used by bison-electric-* functions to determine actions | |||
return t if within a production, nil if not | |||
a point is within a production if there is some non whitespace text before | |||
either the beginnings of another production or the end of the grammar rules" | |||
(save-excursion | |||
(let ((bound (cond ((bison--find-next-production)) | |||
((bison--find-grammar-end)) | |||
(t nil)))) | |||
(if bound | |||
(let ((sval (re-search-forward | |||
(concat "\\(\\s \\|" ;; whitespace or | |||
;; comments | |||
(regexp-quote comment-start) | |||
"\\(.\\|\n\\)*" ;; comment body | |||
(regexp-quote comment-end) | |||
"\\)+") ;; end or | |||
bound t))) | |||
(if sval | |||
(not (= sval bound)) | |||
nil)) | |||
nil)))) | |||
(defun bison--within-some-sexp-p (starter ender) | |||
"return t if the \(point\) is within the sexp marked by the re's STARTER and | |||
ENDER" | |||
(save-excursion | |||
(let ((current-point (point))) | |||
(if (re-search-backward starter nil t) ;; find nearest starter | |||
;; look for ender, if found, then not within sexp | |||
(progn | |||
(goto-char (match-end 0)) | |||
(not (re-search-forward ender current-point t))))))) | |||
(defun bison--within-c-comment-p () | |||
"return t if the point is within a c comment delimited by \"/*\" \"*/\"" | |||
(bison--within-some-sexp-p (regexp-quote comment-start) | |||
(regexp-quote comment-end))) | |||
(defun bison--within-string-p (&optional point) | |||
" | |||
start from the beginning of the buffer and toggle state as un-escaped \"'s are | |||
found." | |||
(let ((point (or point (point))) | |||
(in-p nil)) | |||
(save-excursion | |||
(goto-char (point-min)) | |||
(while (re-search-forward "[^\\]\"" point t) | |||
(setq in-p (not in-p))) | |||
in-p))) | |||
;;; bison--within-braced-c-expression-p | |||
;;; new and improved, no more recursion, does not break when literal strings | |||
;;; contain un-matched braces | |||
(defun bison--within-braced-c-expression-p (section) | |||
"return t if the point is within an sexp delimited by braces \({,}\) | |||
" | |||
(save-excursion | |||
(bison--within-braced-c-expression-p-h section (point)))) | |||
(defun bison--within-braced-c-expression-p-h (section low-pt) | |||
" | |||
Notes: | |||
save excursion is done higher up, so i dont concern myself here. | |||
" | |||
(cond ((= section bison--pre-c-decls-section) nil) | |||
((= section bison--c-decls-section) | |||
(let ((opener (save-excursion (search-backward "%{")))) | |||
(bison--within-braced-c-expression-p-h-h opener low-pt))) | |||
((= section bison--bison-decls-section) | |||
(let ((opener (save-excursion | |||
(or (search-backward "%}" nil t) | |||
(point-min))))) | |||
(bison--within-braced-c-expression-p-h-h opener low-pt))) | |||
((= section bison--grammar-rules-section) | |||
(let ((opener (save-excursion (bison--find-production-opener)))) | |||
(if opener | |||
(bison--within-braced-c-expression-p-h-h opener low-pt) | |||
nil))) | |||
((= section bison--c-code-section) | |||
t))) | |||
(defun bison--within-braced-c-expression-p-h-h (high-pt low-pt) | |||
" | |||
Notes: | |||
HIGH-PT goes toward (point-min), LOW-PT goes toward (point-max) | |||
save excursion is done higher up, so i dont concern myself here. | |||
" | |||
(let ((pt (point))) | |||
(let ((success nil) (count 1) (done nil)) | |||
;; loop until open brace found, that is not in comment or string literal | |||
(while (and (not done) | |||
(re-search-backward "[^%]{" high-pt t count)) ;find nearest | |||
;starter | |||
(goto-char (match-end 0)) | |||
(if (or (bison--within-c-comment-p) | |||
(bison--within-string-p)) | |||
(setq count (+ count 1)) | |||
(progn | |||
(setq success t) | |||
(setq done t)))) | |||
(if success | |||
(let ((end-pt | |||
(condition-case nil | |||
(progn | |||
(backward-char) | |||
(forward-sexp) | |||
(point)) | |||
(error nil)))) | |||
(if end-pt | |||
(if (> end-pt low-pt) | |||
t ; then in braced-c-exp | |||
nil) | |||
t)) ; if no sexp close brace, then w/in | |||
nil)))) | |||
(defun bison--bison-decl-opener-p (bol eol) | |||
"return t if the current line is a bison declaration starter | |||
\(i.e. has a %type, %token, %right, ...\)" | |||
(save-excursion | |||
(goto-char bol) | |||
(re-search-forward | |||
(concat "^" (regexp-opt (copy-sequence bison--declarers))) eol t))) | |||
(defun bison--production-opener-p (bol eol) | |||
"return t if the current line is a line that introduces a new production" | |||
(save-excursion | |||
(goto-char bol) | |||
(re-search-forward bison--production-re eol t))) | |||
(defun bison--find-bison-semicolon () | |||
"return the position of next semicolon not within braces, nil otherwise" | |||
(save-excursion | |||
(if (search-forward ";" nil t) | |||
(if (not (bison--within-braced-c-expression-p (bison--section-p))) | |||
(point) | |||
(bison--find-bison-semicolon)) | |||
nil))) | |||
(defun bison--within-production-body-p (section) | |||
"return t if the \(point\) is within the body of a production | |||
this procedure will fail if it is in a production header" | |||
(save-excursion | |||
(if (= section bison--grammar-rules-section) | |||
(let ((current-point (point))) | |||
(if (re-search-backward bison--production-re nil t) | |||
t | |||
nil)) | |||
nil))) | |||
(defun bison--production-alternative-p (bol eol section) | |||
"return t if the current line contains a \"|\" used to designate a rule | |||
alternative" | |||
(save-excursion | |||
(goto-char bol) | |||
(if (search-forward "|" eol t) | |||
(not (bison--within-braced-c-expression-p section)) | |||
nil))) | |||
;; *************** indent functions *************** | |||
(defun bison--handle-indent-c-sexp (section indent-column bol) | |||
(let* ((o-brace (re-search-backward "[^%]{" bol t)) | |||
) | |||
(if o-brace | |||
(if (save-excursion | |||
(goto-char o-brace) | |||
(bison--within-braced-c-expression-p section)) | |||
(c-indent-line) | |||
(if (= (current-indentation) o-brace) ;; if o-brace is first char | |||
(if (not (= o-brace indent-column)) ;; but not in right spot | |||
(progn | |||
(back-to-indentation) | |||
(just-no-space) | |||
(indent-to-column indent-column)) | |||
;; else all is good | |||
) | |||
;; else, non-ws before o-brace, leave it alone | |||
)) | |||
(c-indent-line)))) | |||
(defun bison-indent-new-line (&optional c-sexp) | |||
"Indent a fresh line of bison code | |||
assumes indenting a new line, i.e. at column 0 | |||
" | |||
(interactive) | |||
(let* ((section (bison--section-p)) | |||
(c-sexp (or c-sexp (bison--within-braced-c-expression-p section))) | |||
) | |||
(cond | |||
(c-sexp | |||
(cond | |||
((= section bison--grammar-rules-section) | |||
(c-indent-line | |||
(save-excursion | |||
(forward-line -1) | |||
(let ((bol (save-excursion (beginning-of-line) (point))) | |||
(eol (save-excursion (end-of-line) (point)))) | |||
(if (bison--production-opener-p bol eol) | |||
(list | |||
(cons 'defun-block-intro | |||
(progn | |||
(re-search-forward bison--production-re) ; SIGERR | |||
(- (re-search-forward "[^ \t]") ; SIGERR | |||
1)))) | |||
nil))))) | |||
(t (c-indent-line)))) | |||
((= section bison--pre-c-decls-section) | |||
(c-indent-line)) | |||
((= section bison--bison-decls-section) | |||
(indent-to-column bison-decl-token-column)) | |||
((= section bison--grammar-rules-section) | |||
(indent-to-column | |||
(save-excursion | |||
(let* ((bound (or (save-excursion (bison--find-production-opener)) | |||
(bison--find-grammar-begin))) | |||
(prev-semi (search-backward ";" bound t)) | |||
) | |||
(if prev-semi | |||
(if (bison--within-braced-c-expression-p section) ; CRACK | |||
bison-rule-enumeration-column | |||
0) | |||
(if (save-excursion (bison--find-production-opener)) | |||
bison-rule-enumeration-column | |||
0)))))) | |||
((= section bison--c-code-section)) ;;leave-alone | |||
))) | |||
(defun bison-indent-line () | |||
"Indent a line of bison code." | |||
(interactive) | |||
(let* ((pos (- (point-max) (point))) | |||
(reset-pt (function (lambda () | |||
(if (> (- (point-max) pos) (point)) | |||
(goto-char (- (point-max) pos)))))) | |||
(bol (save-excursion (beginning-of-line) (point))) | |||
(eol (save-excursion (end-of-line) (point))) | |||
) | |||
(let* ((section (bison--section-p)) | |||
(c-sexp (bison--within-braced-c-expression-p section)) | |||
(ws-line (line-of-whitespace-p)) | |||
) | |||
(cond | |||
;; if you are a line of whitespace, let indent-new-line take care of it | |||
(ws-line | |||
(bison-indent-new-line c-sexp)) | |||
((= section bison--pre-c-decls-section) | |||
;; leave things alone | |||
) | |||
((= section bison--c-decls-section) | |||
(if c-sexp | |||
(bison--handle-indent-c-sexp section 0 bol) | |||
(if (not (= (current-indentation) 0)) | |||
(progn | |||
(back-to-indentation) | |||
(just-no-space) | |||
(funcall reset-pt))))) | |||
((= section bison--bison-decls-section) | |||
(let ((opener (bison--bison-decl-opener-p bol eol))) | |||
(cond | |||
(opener | |||
(goto-char opener) | |||
(skip-chars-forward " \t" eol) | |||
(if (looking-at "{") | |||
(save-excursion | |||
(if (following-non-ws-p) | |||
(progn | |||
(forward-char 1) | |||
(just-no-space) | |||
(newline) | |||
(bison-indent-new-line t)))) | |||
(let ((complete-type t)) | |||
(if (looking-at "<") | |||
(progn | |||
(setq complete-type nil) | |||
(if (not (= (current-column) bison-decl-type-column)) | |||
(progn | |||
(just-no-space) | |||
(indent-to-column bison-decl-type-column)) | |||
(and (re-search-forward | |||
(concat "<" bison--word-constituent-re "+>") | |||
eol t) | |||
(setq complete-type t))))) | |||
(and complete-type | |||
(skip-chars-forward " \t" eol) | |||
(looking-at | |||
(concat "\\(" bison--word-constituent-re "\\|'\\)")) | |||
(if (not (= (current-column) bison-decl-token-column)) | |||
(progn | |||
(just-no-space) | |||
(indent-to-column bison-decl-token-column)))))) | |||
(funcall reset-pt)) | |||
(c-sexp | |||
(bison--handle-indent-c-sexp section 0 bol)) | |||
(t | |||
(back-to-indentation) | |||
;; only tab in names, leave comments alone | |||
(cond (;; put word-constiuents in bison-decl-token-column | |||
(looking-at bison--word-constituent-re) | |||
(if (not (= (current-column) bison-decl-token-column)) | |||
(progn | |||
(just-no-space) | |||
(indent-to-column bison-decl-token-column)))) | |||
;; put/keep close-brace in the 0 column | |||
((looking-at "}") | |||
(if (not (= (current-column) 0)) | |||
(just-no-space))) | |||
;; leave comments alone | |||
((looking-at (regexp-quote comment-start)) nil) | |||
;; else do nothing | |||
) | |||
(funcall reset-pt))))) | |||
((= section bison--grammar-rules-section) | |||
(cond | |||
((bison--production-opener-p bol eol) | |||
(beginning-of-line) | |||
(re-search-forward bison--production-re);; SIGERR | |||
(if (following-non-ws-p) | |||
(if (> (current-column) bison-rule-enumeration-column) | |||
(progn | |||
(just-no-space) | |||
(newline) | |||
(indent-to-column bison-rule-enumeration-column)) | |||
(save-excursion | |||
(re-search-forward bison--word-constituent-re);; SIGERR | |||
(let ((col (current-column))) | |||
(cond ((> col (+ 1 bison-rule-enumeration-column)) | |||
(forward-char -1) | |||
(just-no-space) | |||
(indent-to-column bison-rule-enumeration-column)) | |||
((< col (+ 1 bison-rule-enumeration-column)) | |||
(forward-char -1) | |||
(indent-to-column | |||
bison-rule-enumeration-column))))))) | |||
(funcall reset-pt)) | |||
((bison--production-alternative-p bol eol section) | |||
(back-to-indentation);; should put point on "|" | |||
(if (not (= (current-column) bison-rule-separator-column)) | |||
(progn | |||
(just-no-space) | |||
(indent-to-column bison-rule-separator-column))) | |||
(forward-char 1) | |||
(if (following-non-ws-p) | |||
(save-excursion | |||
(re-search-forward bison--word-constituent-re);; SIGERR | |||
(let ((col (current-column))) | |||
(cond ((> col (+ 1 bison-rule-enumeration-column)) | |||
(forward-char -1) | |||
(just-no-space) | |||
(indent-to-column bison-rule-enumeration-column)) | |||
((< col (+ 1 bison-rule-enumeration-column)) | |||
(forward-char -1) | |||
(indent-to-column | |||
bison-rule-enumeration-column)))))) | |||
(funcall reset-pt)) | |||
(c-sexp | |||
(bison--handle-indent-c-sexp | |||
section bison-rule-enumeration-column bol) | |||
(funcall reset-pt)) | |||
((bison--within-production-body-p section) | |||
(back-to-indentation) | |||
(if (not (= (current-column) bison-rule-enumeration-column)) | |||
(progn | |||
(just-no-space) | |||
(indent-to-column | |||
bison-rule-enumeration-column))) | |||
(funcall reset-pt)) | |||
(t | |||
(let ((cur-ind (current-indentation))) | |||
(if (eq (save-excursion (search-backward "}" bol t)) | |||
cur-ind) | |||
(if (not (= cur-ind bison-rule-enumeration-column)) | |||
(progn | |||
(back-to-indentation) | |||
(just-no-space) | |||
(indent-to-column bison-rule-enumeration-column) | |||
(funcall reset-pt))) | |||
;; else leave alone | |||
))))) | |||
((= section bison--c-code-section) | |||
(c-indent-line)) | |||
)))) | |||
;; *************** electric-functions *************** | |||
(defun bison-electric-colon (arg) | |||
"If the colon <:> delineates a production, | |||
then insert a semicolon on the next line in the BISON-RULE-SEPARATOR-COLUMN, | |||
put the cursor in the BISON-RULE-ENUMERATION-COLUMN for the beginning | |||
of the rule | |||
else just run self-insert-command | |||
A colon delineates a production by the fact that it is immediately preceded by | |||
a word(alphanumerics or '_''s), and there is no previous white space. | |||
" | |||
(interactive "P") | |||
(self-insert-command (prefix-numeric-value arg)) | |||
(if (and bison-electric-colon-v | |||
(not bison-all-electricity-off)) | |||
(if (and (= bison--grammar-rules-section (bison--section-p)) | |||
(bison--production-p) | |||
(not (bison--within-started-production-p))) | |||
(progn | |||
(save-excursion ; put in a closing semicolon | |||
(newline) | |||
(indent-to-column bison-rule-separator-column) | |||
(insert ";")) | |||
(save-excursion ; remove opening whitespace | |||
(if (re-search-backward | |||
"\\s " | |||
(save-excursion (beginning-of-line) (point)) | |||
t) | |||
(just-no-space))) | |||
(if (not (< (current-column) bison-rule-enumeration-column)) | |||
(newline)) | |||
(indent-to-column bison-rule-enumeration-column))))) | |||
(defun bison-electric-pipe (arg) | |||
"If the pipe <|> is used as a rule separator within a production, | |||
then move it into BISON-RULE-SEPARATOR-COLUMN | |||
indent to BISON-RULE-ENUMERATION-COLUMN on the same line | |||
else just run self-insert-command | |||
" | |||
(interactive "P") | |||
(if (and bison-electric-pipe-v | |||
(not bison-all-electricity-off) | |||
(= bison--grammar-rules-section (bison--section-p)) | |||
(line-of-whitespace-p) | |||
) | |||
(progn | |||
(beginning-of-line) | |||
(just-no-space) | |||
(indent-to-column bison-rule-separator-column) | |||
(self-insert-command (prefix-numeric-value arg)) | |||
(indent-to-column bison-rule-enumeration-column) | |||
) | |||
(self-insert-command (prefix-numeric-value arg)))) | |||
(defun bison-electric-open-brace (arg) | |||
"used for the opening brace of a C action definition for production rules, | |||
if there is only whitespace before \(point\), then put open-brace in | |||
bison-rule-enumeration-column" | |||
(interactive "P") | |||
(if (and bison-electric-open-brace-v | |||
(not bison-all-electricity-off)) | |||
(let ((section (bison--section-p))) | |||
(cond ((and (= section bison--grammar-rules-section) | |||
(not (bison--within-braced-c-expression-p section)) | |||
(not (previous-non-ws-p))) | |||
(if (not (= (current-column) bison-rule-enumeration-column)) | |||
(progn | |||
(just-no-space) | |||
(indent-to-column bison-rule-enumeration-column)))) | |||
((and (= section bison--bison-decls-section) | |||
(not (bison--within-braced-c-expression-p section)) | |||
(not (previous-non-ws-p))) | |||
(if (not (= (current-column) 0)) | |||
(progn | |||
(just-no-space) | |||
(indent-to-column 0))))))) | |||
(self-insert-command (prefix-numeric-value arg))) | |||
(defun bison-electric-close-brace (arg) | |||
"If the close-brace \"}\" is used as the c-declarations section closer | |||
in \"%}\", then make sure the \"%}\" indents to the beginning of the line" | |||
(interactive "P") | |||
(self-insert-command (prefix-numeric-value arg)) | |||
(if (and bison-electric-close-brace-v | |||
(not bison-all-electricity-off)) | |||
(cond ((search-backward "%}" (- (point) 2) t) | |||
(if (= (bison--section-p) bison--c-decls-section) | |||
(progn | |||
(just-no-space) | |||
(forward-char 2)) ; for "%}" | |||
(forward-char 1))) | |||
))) | |||
(defun bison-electric-semicolon (arg) | |||
"if the semicolon is used to end a production, then place it in | |||
bison-rule-separator-column | |||
a semicolon is deemed to be used for ending a production if it is not found | |||
within braces | |||
this is just self-insert-command as i have yet to write the actual | |||
bison-electric-semicolon function yet | |||
" | |||
(interactive "P") | |||
(self-insert-command (prefix-numeric-value arg))) | |||
(defun bison-electric-percent (arg) | |||
"If the percent is a declarer in the bison declaration's section, | |||
then put it in the 0 column." | |||
(interactive "P") | |||
(if (and bison-electric-percent-v | |||
(not bison-all-electricity-off)) | |||
(let ((section (bison--section-p))) | |||
(if (and (= section bison--bison-decls-section) | |||
(not (bison--within-braced-c-expression-p section)) | |||
(not (previous-non-ws-p)) | |||
(not (= (current-column) 0))) | |||
(just-no-space)))) | |||
(self-insert-command (prefix-numeric-value arg))) | |||
(defun bison-electric-less-than (arg) | |||
"If the less-than is a type declarer opener for tokens in the bison | |||
declaration section, then put it in the bison-decl-type-column column." | |||
(interactive "P") | |||
(if (and bison-electric-less-than-v | |||
(not bison-all-electricity-off)) | |||
(if (and (= (bison--section-p) bison--bison-decls-section) | |||
(bison--bison-decl-opener-p | |||
(save-excursion (beginning-of-line) (point)) | |||
(point))) | |||
(progn | |||
(just-no-space) | |||
(indent-to-column bison-decl-type-column)))) | |||
(self-insert-command (prefix-numeric-value arg))) | |||
(defun bison-electric-greater-than (arg) | |||
"If the greater-than is a type declarer closer for tokens in the bison | |||
declaration section, then indent to bison-decl-token-column." | |||
(interactive "P") | |||
(self-insert-command (prefix-numeric-value arg)) | |||
(if (and bison-electric-greater-than-v | |||
(not bison-all-electricity-off)) | |||
(let ((current-pt (point)) | |||
(bol (save-excursion (beginning-of-line) (point)))) | |||
(if (and (= (bison--section-p) bison--bison-decls-section) | |||
(bison--bison-decl-opener-p bol (point))) | |||
(if (search-backward "<" bol t) | |||
(if (re-search-forward | |||
(concat "<" bison--word-constituent-re "+>") | |||
current-pt t) | |||
(if (not (following-non-ws-p)) | |||
(progn | |||
(just-no-space) | |||
(indent-to-column bison-decl-token-column))))))))) | |||
;;;###autoload | |||
(define-derived-mode jison-mode bison-mode "jison" | |||
"Major mode for editing jison files.") | |||
;;;###autoload | |||
(define-derived-mode flex-mode bison-mode "flex" | |||
"Major mode for editing flex files. (bison-mode by any other name)") | |||
(provide 'bison-mode) | |||
(provide 'jison-mode) | |||
(provide 'flex-mode) | |||
;;; bison-mode.el ends here |
@ -0,0 +1,13 @@ | |||
/* | |||
* `(buffer-name)` | |||
* | |||
* Created by `(user-full-name)` on `(format-time-string "%d/%m/%Y")`. | |||
* Copyright `user-mail-address`. `(format-time-string "%Y")`. All rights reserved. | |||
*/ | |||
#include <stdio.h> | |||
int main(int argc, char *argv[]) { | |||
} | |||
@ -0,0 +1,13 @@ | |||
/* | |||
* `(buffer-name)` | |||
* | |||
* Created by `user-full-name` on `(format-time-string "%d/%m/%Y")`. | |||
* Copyright `user-mail-address`. `(format-time-string "%Y")`. All rights reserved. | |||
*/ | |||
#include <iostream> | |||
int main(int argc, char *argv[]) { | |||
} | |||
@ -0,0 +1,35 @@ | |||
;;; `(buffer-name)` --- ${1:Description} | |||
;; Author: `user-full-name` `user-mail-address` | |||
;; Keywords: $2 | |||
;; URL: | |||
;; Copyright (C) `(format-time-string ""%Y"")`, `user-full-name`, all rights reserved. | |||
;; 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. | |||
;; You should have received a copy of the GNU General Public License | |||
;; along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
;;; Commentary: | |||
;; | |||
;;; Code: | |||
$0 | |||
(provide '`(substring (buffer-name) 0 (- (length (buffer-name)) 3))`) | |||
;; Local Variables: | |||
;; coding: utf-8 | |||
;; End: | |||
;;; `(buffer-name)` ends here. |
@ -0,0 +1,12 @@ | |||
/* | |||
* `(buffer-name)` | |||
* | |||
* Created by `(user-full-name)` on `(format-time-string "%d/%m/%Y")`. | |||
* Copyright `user-mail-address`. `(format-time-string "%Y")`. All rights reserved. | |||
*/ | |||
#ifndef `(replace-regexp-in-string (regexp-quote ".") "_" (buffer-name) nil 'literal))` | |||
#define `(replace-regexp-in-string (regexp-quote ".") "_" (buffer-name) nil 'literal))` | |||
#endif /* `(replace-regexp-in-string (regexp-quote .) _ buffer-name nil 'literal))` */ |
@ -0,0 +1,12 @@ | |||
/* | |||
* `(buffer-name)` | |||
* | |||
* Created by `(user-full-name)` on `(format-time-string "%d/%m/%Y")`. | |||
* Copyright `user-mail-address`. `(format-time-string "%Y")`. All rights reserved. | |||
*/ | |||
class Untitled { | |||
public static void main(String[] args) { | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
# -*- coding:utf-8 -*- | |||
#+LANGUAGE: en | |||
#+TITLE: ${1:`(file-name-nondirectory (buffer-file-name))`} | |||
#+AUTHOR: `user-full-name` | |||
#+EMAIL: `user-mail-address` | |||
#+DATE: `(format-time-string "%Y-%m-%d %a" )` | |||
#+DESCRIPTION:$1 | |||
#+KEYWORDS: $2 | |||
#+TAGS:$3 | |||
#+FILETAGS: $4 | |||
#+OPTIONS: H:2 num:nil toc:t \n:t @:t ::t |:t ^:nil -:t f:t *:t <:t | |||
#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil | |||
#+LATEX_HEADER: \usepackage{fontspec} |
@ -0,0 +1,14 @@ | |||
#!/bin/python | |||
# | |||
# `(buffer-name)` | |||
# | |||
# Created by `(user-full-name)` on `(format-time-string "%d/%m/%Y")`. | |||
# Copyright `user-mail-address`. `(format-time-string "%Y")`. All rights reserved. | |||
# | |||
def main(): | |||
print("hello world") | |||
if __name__ == "__main__": | |||
main() |
@ -0,0 +1,7 @@ | |||
#!/bin/sh | |||
# `(buffer-name)` | |||
# | |||
# Created by `(user-full-name)` on `(format-time-string "%d/%m/%Y")`. | |||
# Copyright `user-mail-address`. `(format-time-string "%Y")`. All rights reserved. | |||
@ -0,0 +1,14 @@ | |||
#!/bin/sh | |||
chosen=$(cut -d ';' -f1 ~/.local/share/emoji | dmenu -i -l 10 | sed "s/ .*//") | |||
[ -z "$chosen" ] && exit | |||
if [ -n "$1" ]; then | |||
xdotool type "$chosen" | |||
else | |||
printf "$chosen" | xclip -selection clipboard | |||
printf %s "$chosen" | xdotool type --clearmodifiers --file - | |||
notify-send -a "Character copied to clipboard" "'$chosen' copied to clipboard." & | |||
fi |
@ -0,0 +1,107 @@ | |||
#!/bin/sh | |||
# title: dmenu_websearch <http://efe.kim/dmenu_websearch.html> | |||
# license: CC0 | |||
# author: Sunur Efe Vural <efe@efe.kim> | |||
# version: Mar 22, 2019 | |||
# dependencies: dmenu, xdotool, hexdump, xprop, setxkbmap, coreutils. | |||
# A browser-independent address bar with bookmark support. When the | |||
# cursor is on a web browser it acts as the address bar of that browser. | |||
engine='https://anon.sx/search?q=%s' | |||
bookmarks="$HOME/.local/share/bookmarks" | |||
gotourl() { | |||
if [ "$nbrowser" = surf ] | |||
then | |||
xprop -id "$winid" -f _SURF_GO 8s -set _SURF_GO "$choice" | |||
elif [ -n "$winid" ] && [ -z "$nbrowser" ] | |||
then | |||
#change layout to us cuz xdotool spasms with non-latin layouts | |||
layout=$(setxkbmap -query | awk '/^layout:/{ print $2 }') | |||
setxkbmap -layout us | |||
xdotool key --clearmodifiers "$shortcut"\ | |||
type --clearmodifiers --delay 2 "$choice" | |||
xdotool key --clearmodifiers Return | |||
setxkbmap -layout "$layout" | |||
elif [ -n "$nbrowser" ] | |||
then | |||
$nbrowser "$choice" | |||
else $BROWSER "$choice" | |||
fi | |||
} | |||
searchweb() { | |||
#convert search query to percent encoding and insert it into url | |||
choice=$(echo "$choice" | hexdump -v -e '/1 " %02x"') | |||
choice=$(echo "$engine" | sed "s/%s/${choice% 0a}/;s/[[:space:]]/%/g") | |||
gotourl | |||
} | |||
xprop -root | grep '^_NET_ACTIVE_WINDOW' && { | |||
winid=$(xprop -root _NET_ACTIVE_WINDOW | sed 's/.*[[:space:]]//') | |||
class=$(xprop -id "$winid" WM_CLASS | awk -F'\"' '{ print $(NF - 1) }') | |||
case "$class" in | |||
Firefox) nbrowser='firefox' ;; | |||
#Firefox) shortcut='ctrl+l' ;; # alternative method, uses xdotool | |||
IceCat) nbrowser='icecat' ;; | |||
Chromium) nbrowser='chromium' ;; | |||
Chrome) nbrowser='chrome' ;; | |||
Opera) nbrowser='opera' ;; | |||
Vivaldi) nbrowser='vivaldi' ;; # not tested | |||
Brave) nbrowser='brave' ;; # not tested | |||
Conkeror) nbrowser='conkeror' ;; # not tested | |||
Palemoon) nbrowser='palemoon' ;; # not tested | |||
Iceweasel) nbrowser='iceweasel' ;; # not tested | |||
qutebrowser) nbrowser='qutebrowser' ;; | |||
Midori) nbrowser='midori' ;; # not that good | |||
Luakit) nbrowser='luakit' ;; # uses the last window instance | |||
Uzbl|Vimb) shortcut='o' ;; | |||
Links) shortcut='g' ;; | |||
Netsurf*|Epiphany|Dillo|Konqueror|Arora) shortcut='ctrl+l' ;; | |||
Surf) nbrowser='surf' ; uricur=$(xprop -id "$winid" _SURF_URI |\ | |||
awk -F'\"' '{ print $( NF - 1 ) }') ;; | |||
*) pid=$(xprop -id "$winid" _NET_WM_PID | awk '{ print $3 }') | |||
while pgrep -oP "$pid" >/dev/null | |||
do | |||
pid=$(pgrep -oP "$pid") | |||
done | |||
pname=$(awk '/^Name\:/{ print $NF }' /proc/"$pid"/status) || | |||
winid="" ;; | |||
esac | |||
[ -n "$pname" ] && case "$pname" in | |||
w3m) shortcut="U" ;; | |||
lynx|elinks|links) shortcut="g" ;; | |||
*) winid="" ;; | |||
esac | |||
} | |||
tmpfile=$(mktemp /tmp/dmenu_websearch.XXXXXX) | |||
trap 'rm "$tmpfile"' 0 1 15 | |||
printf '%s\n%s\n' "$uricur" "$1" > "$tmpfile" | |||
cat "$bookmarks" >> "$tmpfile" | |||
sed -i -E '/^(#|$)/d' "$tmpfile" | |||
choice=$(dmenu -i -p "Go:" -w "$winid" < "$tmpfile") || exit 1 | |||
# Detect links without protocol (This is WIP) | |||
protocol='^(https?|ftps?|mailto|about|file):///?' | |||
checkurl() { | |||
grep -Fx "$choice" "$tmpfile" && | |||
choice=$(echo "$choice" | awk '{ print $1 }') && return 0 | |||
[ ${#choice} -lt 4 ] && return 1 | |||
echo "$choice" | grep -Z ' ' && return 1 | |||
echo "$choice" | grep -EiZ "$protocol" && return 0 | |||
echo "$choice" | grep -FZ '..' && return 1 | |||
prepath=$(echo "$choice" | sed 's/(\/|#|\?).*//') | |||
echo "$prepath" | grep -FvZ '.' && return 1 | |||
echo "$prepath" | grep -EZ '^([[:alnum:]~_:-]+\.?){1,3}' && return 0 | |||
} | |||
if checkurl | |||
then | |||
echo "$choice" | grep -EivZ "$protocol" && | |||
choice="http://$choice" | |||
gotourl | |||
else searchweb | |||
fi |
@ -0,0 +1,318 @@ | |||
#!/usr/bin/zsh | |||
# | |||
# Setup outputs with xrandr as a backend and dmenu as a frontend | |||
# | |||
# external commands: cat, cut, dmenu, grep, sed, xrandr | |||
# Released under GPLv2 | |||
# | |||
# TODO: add dpi support | |||
typeset XRANDR_TXT # readonly; stdout of running xrandr without any options | |||
typeset -A OUTPUT_CONFIGURED # key=connected output name | |||
typeset -a DISCONNECT_OUTPUTS | |||
typeset OPT_MODE='auto' | |||
typeset OPT_ROTATION='normal' | |||
typeset -ir EXIT_CLEAN=7 | |||
typeset -ir ERR_BAD_ARGS=257 | |||
typeset -ir ERR_BAD_SELECTION=258 | |||
typeset -ir ERR_NO_OPTIONS=259 | |||
if ! command -v cat &>/dev/null; then | |||
echo 'coreutils seem to be missing. You'\''re gonna have a bad time.' >&2 | |||
exit 255 | |||
elif ! command -v grep &>/dev/null; then | |||
echo 'grep seems to be missing. You'\''re gonna have a bad time.' >&2 | |||
exit 255 | |||
elif ! command -v xrandr &>/dev/null; then | |||
echo 'Ran xrandr-dmenu without xrandr? You'\''re gonna have a bad time.' >&2 | |||
exit 255 | |||
elif ! command -v dmenu &>/dev/null; then | |||
echo 'Ran xrandr-dmenu without dmenu? You'\''re gonna have a bad time.' >&2 | |||
exit 255 | |||
elif ! xset q &>/dev/null; then | |||
echo 'Woah there, cowboy! You need to run this from inside X!' >&2 | |||
exit 1 | |||
fi | |||
XRANDR_TXT="$(xrandr)" || exit $? | |||
function () { | |||
typeset opt | |||
typeset output | |||
typeset help_msg="usage: xrandr-dmenu [options] | |||
Setup X outputs position, mode, etc | |||
Input 'exit' or press 'ESC' at any point to cancel. | |||
Options: | |||
-m Select mode for outputs | |||
-M Use current mode for outputs | |||
-r Select rotation for outputs | |||
-R Use current rotation for outputs" | |||
while getopts mMrRh opt; do | |||
case "${opt}" in | |||
('m') OPT_MODE='change' ;; | |||
('M') OPT_MODE='no_change' ;; | |||
('r') OPT_ROTATION='change' ;; | |||
('R') OPT_ROTATION='no_change' ;; | |||
('h') | |||
echo "${help_msg}" | |||
exit 0 | |||
;; | |||
('?') | |||
echo "${help_msg}" | |||
exit 1 | |||
;; | |||
esac | |||
done | |||
for output in $(grep ' connected' <<< "${XRANDR_TXT}" | cut -d ' ' -f 1); do | |||
OUTPUT_CONFIGURED[${output}]='false' | |||
done | |||
for output ($(grep ' disconnected' <<< "${XRANDR_TXT}" | cut -d ' ' -f 1)) { | |||
DISCONNECTED_OUTPUTS+=("${output}") | |||
} | |||
} "$@" | |||
typeset -r XRANDR_TXT | |||
typeset -r OPT_MODE | |||
typeset -r OPT_ROTATION | |||
typeset -r DISCONNECTED_OUTPUTS | |||
function main() { | |||
typeset prompt | |||
typeset menu | |||
typeset output | |||
typeset mode | |||
typeset rotation | |||
typeset position | |||
typeset xrandr_cmd | |||
# set primary output | |||
prompt='Select primary output:' | |||
output="$(menu_select "${prompt}" ${(k)=OUTPUT_CONFIGURED})" || bail $? | |||
position='--primary' | |||
mode="$(select_mode ${output})" || bail $? | |||
rotation="$(select_rotation ${output})" || bail $? | |||
OUTPUT_CONFIGURED[${output}]='true' | |||
xrandr_cmd="xrandr --output ${output} ${position} ${rotation} ${mode}" | |||
# set additional outputs | |||
prompt='Select next output:' | |||
while ! all_outputs_configured; do | |||
menu="$(list_unconfigured_outputs)" | |||
output="$(menu_select ${prompt} ${=menu})" || bail $? | |||
position="$(select_position ${output})" || bail $? | |||
if [[ "${position}" != '--off' ]]; then | |||
mode="$(select_mode ${output})" || bail $? | |||
rotation="$(select_rotation ${output})" || bail $? | |||
fi | |||
OUTPUT_CONFIGURED[${output}]='true' | |||
xrandr_cmd+=" --output ${output} ${position} ${rotation} ${mode}" | |||
done | |||
# forcibly '--off' disconnected outputs | |||
for output in ${DISCONNECTED_OUTPUTS}; do | |||
xrandr_cmd+=" --output ${output} --off" | |||
done | |||
# do the deed | |||
if ! ${=xrandr_cmd}; then | |||
echo "Failed to execute xrandr command:\n${xrandr_cmd}" | |||
bail 255 | |||
fi | |||
} | |||
################################################################################ | |||
# Uses dmenu to select the position of a given output relative to an already | |||
# configured output. --same-as and --off are considered a position. | |||
# Prints in the form of xrandr option (eg, '--right-of DP1') to stdout | |||
# Global variables: | |||
# ERR_BAD_ARG | |||
# Arguments: | |||
# $1=name of output to configure | |||
# Returns: | |||
# ERR_BAD_ARG for no $1 | |||
################################################################################ | |||
function select_position() { | |||
[[ -z $1 ]] && return "${ERR_BAD_ARG}" | |||
typeset output | |||
typeset prompt | |||
typeset -a menu | |||
typeset anchor | |||
typeset position | |||
typeset selection | |||
output="$1" | |||
prompt="Select position of ${output}:" | |||
for anchor in $(list_configured_outputs); do | |||
for position in 'left of' 'right of' 'above' 'below' 'same as'; do | |||
menu+=("${position} ${anchor}") | |||
done | |||
done | |||
menu+=('off') | |||
selection="$(menu_select "${prompt}" ${menu})" || return $? | |||
case "${selection[(w)1]}" in | |||
(left|right|same) echo "--${selection/ /-}" ;; | |||
(above|below|mirror|off) echo "--${selection}" ;; | |||
esac | |||
} | |||
################################################################################ | |||
# Uses dmenu to display the detected mode options for a given output and lets | |||
# the user select a mode to use. Prints choice in xrandr option format | |||
# (eg, '--mode 800x600' or '--auto') to stdout | |||
# Global variables: | |||
# XRANDR_TXT | |||
# OPT_MODE | |||
# ERR_BAD_ARGS | |||
# Arguments: | |||
# $1 - name of which output we are working with | |||
# Returns: | |||
# ERR_BAD_ARGS | |||
################################################################################ | |||
function select_mode() { | |||
[[ -z $1 ]] && return "${ERR_BAD_ARGS}" | |||
typeset output | |||
typeset prompt | |||
typeset menu | |||
typeset selection | |||
output="$1" | |||
prompt="Select mode for ${output}:" | |||
if [[ "${OPT_MODE}" == 'auto' ]]; then | |||
echo '--auto' | |||
elif [[ "${OPT_MODE}" == 'no_change' ]]; then | |||
echo '' | |||
else | |||
# TODO: make this not ugly. A better sed should negate the need for cut/grep | |||
menu="$(echo \"${XRANDR_TXT}\" \ | |||
| sed -n '/^'${output}' /,/^[^ ]/ s/ * //p' \ | |||
| cut -d ' ' -f 1 \ | |||
| grep x \ | |||
| cat <(echo auto) -)" | |||
selection="$(menu_select "${prompt}" ${=menu})" || return $? | |||
if [[ 'auto' == "${selection}" ]]; then | |||
echo '--auto' | |||
else | |||
echo "--mode ${selection}" | |||
fi | |||
fi | |||
} | |||
################################################################################ | |||
# Uses dmenu to select the rotation of a given output. Prints the selection in | |||
# xrandr option format (eg '--rotate inverted') to stdout | |||
# Global variables: | |||
# OPT_ROTATION | |||
# ERR_BAD_ARGS | |||
# Arguments: | |||
# $1 - name of which output we are working with | |||
# Returns: | |||
# ERR_BAD_ARGS | |||
################################################################################ | |||
function select_rotation() { | |||
[[ -z $1 ]] && return "${ERR_BAD_ARGS}" | |||
typeset menu | |||
typeset prompt | |||
prompt="Select rotation of $1:" | |||
menu=('normal' 'inverted' 'left' 'right') | |||
if [[ "${OPT_ROTATION}" == 'normal' ]]; then | |||
echo '--rotate normal' | |||
elif [[ "${OPT_ROTATION}" == 'no_change' ]]; then | |||
echo '' | |||
else | |||
echo -n "--rotate ${selection}" | |||
menu_select "${prompt}" ${menu} || return $? | |||
fi | |||
} | |||
################################################################################ | |||
# Uses dmenu to select an option. Undisplayed 'exit' option or pressing 'ESC' | |||
# will return code ${EXIT_CLEAN} to trigger an abort to the script. Validates to | |||
# make sure the selection is an option. If there is only 1 option, it will | |||
# automatically choose it. Prints selection to stdout | |||
# Global variables: | |||
# none | |||
# Arguments: | |||
# $1=prompt | |||
# $2+=menu items | |||
# Returns: | |||
# ERR_BAD_ARGS=bad arguments | |||
# EXIT_CLEAN=user requested exit | |||
################################################################################ | |||
function menu_select() { | |||
[[ -z "$2" ]] && return ${ERR_BAD_ARGS} | |||
typeset selection | |||
typeset prompt | |||
typeset -a menu | |||
prompt="$1" | |||
shift | |||
menu=($*) | |||
if [[ ${#menu} == 1 ]]; then | |||
echo "${menu}" | |||
else | |||
while [[ -z "${menu[(r)${selection}]}" ]]; do | |||
echo "${(F)menu}" | dmenu -p "${prompt}" | read selection | |||
[[ "${(L)selection}" == 'exit' ]] || [[ -z "${selection}" ]] \ | |||
&& return ${EXIT_CLEAN} | |||
done | |||
echo "${selection}" | |||
fi | |||
} | |||
function list_configured_outputs() { | |||
typeset -a list | |||
typeset output | |||
for output in ${(k)OUTPUT_CONFIGURED}; do | |||
${OUTPUT_CONFIGURED[$output]} && list+=("${output}") | |||
done | |||
echo "${(F)list}" | |||
} | |||
function list_unconfigured_outputs() { | |||
typeset -a list | |||
typeset output | |||
for output in ${(k)OUTPUT_CONFIGURED}; do | |||
${OUTPUT_CONFIGURED[$output]} || list+=("${output}") | |||
done | |||
echo "${(F)list}" | |||
} | |||
function all_outputs_configured() { | |||
typeset config | |||
for config in ${OUTPUT_CONFIGURED}; do | |||
$config || return 257 | |||
done | |||
return 0 | |||
} | |||
function bail() { | |||
[[ "$1" == ${EXIT_CLEAN} ]] && exit 0 || exit "$1" | |||
} | |||
main | |||
################################################################################ | |||
# vim filetype=zsh autoindent expandtab shiftwidth=2 tabstop=2 | |||
# End | |||
# |
@ -1,11 +0,0 @@ | |||
#!/bin/sh | |||
lines=12 | |||
blacklist='google' | |||
selection=$(echo "" | dmenu -p "Enter URL") | |||
if [ ! -z "$selection" ] | |||
then | |||
$BROWSER $selection | |||
fi |
@ -0,0 +1,62 @@ | |||
#!/bin/bash | |||
force_tty=false | |||
force_wait=false | |||
stdin_mode="" | |||
args=() | |||
while :; do | |||
case "$1" in | |||
-t | -nw | --tty) | |||
force_tty=true | |||
shift ;; | |||
-w | --wait) | |||
force_wait=true | |||
shift ;; | |||
-m | --mode) | |||
stdin_mode=" ($2-mode)" | |||
shift 2 ;; | |||
-h | --help) | |||
echo -e "\033[1mUsage: e [-t] [-m MODE] [OPTIONS] FILE [-]\033[0m | |||
Emacs client convenience wrapper. | |||
\033[1mOptions:\033[0m | |||
\033[0;34m-h, --help\033[0m Show this message | |||
\033[0;34m-t, -nw, --tty\033[0m Force terminal mode | |||
\033[0;34m-w, --wait\033[0m Don't supply \033[0;34m--no-wait\033[0m to graphical emacsclient | |||
\033[0;34m-\033[0m Take \033[0;33mstdin\033[0m (when last argument) | |||
\033[0;34m-m MODE, --mode MODE\033[0m Mode to open \033[0;33mstdin\033[0m with | |||
Run \033[0;32memacsclient --help\033[0m to see help for the emacsclient." | |||
exit 0 ;; | |||
--*=*) | |||
set -- "$@" "${1%%=*}" "${1#*=}" | |||
shift ;; | |||
*) | |||
if [ "$#" = 0 ]; then | |||
break; fi | |||
args+=("$1") | |||
shift ;; | |||
esac | |||
done | |||
if [ ! "${#args[*]}" = 0 ] && [ "${args[-1]}" = "-" ]; then | |||
unset 'args[-1]' | |||
TMP="$(mktemp /tmp/emacsstdin-XXX)" | |||
cat > "$TMP" | |||
args+=(--eval "(let ((b (generate-new-buffer \"*stdin*\"))) (switch-to-buffer b) (insert-file-contents \"$TMP\") (delete-file \"$TMP\")${stdin_mode})") | |||
fi | |||
if [ -z "$DISPLAY" ] || $force_tty; then | |||
if [ "$TERM" = "st-256color" ]; then | |||
TERM=xterm-256color emacsclient --tty -create-frame --alternate-editor="nvim" "${args[@]}" | |||
else | |||
emacsclient --tty -create-frame --alternate-editor="nvim" "${args[@]}" | |||
fi | |||
else | |||
if ! $force_wait; then | |||
args+=(--no-wait); fi | |||
emacsclient -create-frame --alternate-editor="nvim" "${args[@]}" | |||
fi |
@ -1,53 +0,0 @@ | |||
#!/bin/sh | |||
# Menu Surfraw: https://github.com/TomboFry/menu-surfraw | |||
# Modified version of https://github.com/onespaceman/menu-calc to display | |||
# available elvi to use in surfraw then get the search term afterwards and open | |||
# it in your browser of choice. | |||
# Edit here to change what browser you open links in | |||
usage() { | |||
echo "Usage: $0 [OPTIONS] [ELVIS [SEARCHTERM]] | |||
OPTIONS: | |||
-h, --help Displays this message | |||
ELVIS: | |||
This is the same as surfraw, any Elvi you have installed. Can be left | |||
blank, as you will be prompted for this in dmenu/rofi. | |||
SEARCHTERM: | |||
Again, the same as surfraw, the term you are searching for. Can also be | |||
left blank as you will be prompted for this in dmenu/rofi." | |||
exit | |||
} | |||
case $1 in | |||
"-h"|"--help") usage ;; | |||
esac | |||
# Path to menu application | |||
if [[ -n $(command -v dmenu) ]]; then | |||
menu="$(command -v dmenu )" | |||
elif [[ -n $(command -v rofi) ]]; then | |||
menu="$(command -v rofi)" | |||
else | |||
echo "Rofi or dmenu not found, exiting." | |||
exit | |||
fi | |||
answerA=$(echo "$1") | |||
answerB=$(echo "${@:2}") | |||
# Change what to display in rofi/dmenu | |||
# If both the first prompt and second prompt are not empty, it will finally open | |||
# the search in surfraw | |||
action=$(echo "" | $menu -p "$answerA ") | |||
if [ "$action" = "" ]; then | |||
exit | |||
fi | |||
surfraw -browser=$BROWSER $answerA $action | |||
@ -1,14 +0,0 @@ | |||
/* | |||
* [:VIM_EVAL:]expand('%:t')[:END_EVAL:] | |||
* [:VIM_EVAL:]expand('%:p:h:t')[:END_EVAL:] | |||
* | |||
* Created by Yigit Colakoglu on [:VIM_EVAL:]strftime('%m/%d/%y')[:END_EVAL:]. | |||
* Copyright [:VIM_EVAL:]strftime('%Y')[:END_EVAL:]. Yigit Colakoglu. All rights reserved. | |||
*/ | |||
#include <stdio.h> | |||
int main(int argc, char *argv[]) { | |||
} | |||
@ -1,14 +0,0 @@ | |||
/* | |||
* [:VIM_EVAL:]expand('%:t')[:END_EVAL:] | |||
* [:VIM_EVAL:]expand('%:p:h:t')[:END_EVAL:] | |||
* | |||
* Created by Yigit Colakoglu on [:VIM_EVAL:]strftime('%m/%d/%y')[:END_EVAL:]. | |||
* Copyright [:VIM_EVAL:]strftime('%Y')[:END_EVAL:]. Yigit Colakoglu. All rights reserved. | |||
*/ | |||
#include <iostream> | |||
int main(int argc, char *argv[]) { | |||
} | |||
@ -1,13 +0,0 @@ | |||
// | |||
// [:VIM_EVAL:]expand('%:t')[:END_EVAL:] | |||
// [:VIM_EVAL:]expand('%:p:h:t')[:END_EVAL:] | |||
// | |||
// Created by Yigit Colakoglu on [:VIM_EVAL:]strftime('%m/%d/%y')[:END_EVAL:]. | |||
// Copyright [:VIM_EVAL:]strftime('%Y')[:END_EVAL:]. Yigit Colakoglu. All rights reserved. | |||
// | |||
#ifndef [:VIM_EVAL:]substitute(expand('%:t'),'\.',"_","")[:END_EVAL:] | |||
#define [:VIM_EVAL:]substitute(expand('%:t'),'\.',"_","")[:END_EVAL:] | |||
#endif /* [:VIM_EVAL:]substitute(expand('%:t'),'\.',"_","")[:END_EVAL:] */ |
@ -1,13 +0,0 @@ | |||
// | |||
// [:VIM_EVAL:]expand('%:t')[:END_EVAL:] | |||
// [:VIM_EVAL:]expand('%:p:h:t')[:END_EVAL:] | |||
// | |||
// Created by Yigit Colakoglu on [:VIM_EVAL:]strftime('%m/%d/%y')[:END_EVAL:]. | |||
// Copyright [:VIM_EVAL:]strftime('%Y')[:END_EVAL:]. Yigit Colakoglu. All rights reserved. | |||
// | |||
#ifndef [:VIM_EVAL:]substitute(expand('%:t'),'\.',"_","")[:END_EVAL:] | |||
#define [:VIM_EVAL:]substitute(expand('%:t'),'\.',"_","")[:END_EVAL:] | |||
#endif /* [:VIM_EVAL:]substitute(expand('%:t'),'\.',"_","")[:END_EVAL:] */ |
@ -1,13 +0,0 @@ | |||
home/home/ | |||
home/home/ [:VIM_EVAL:]expand('%:t')[:END_EVAL:] | |||
home/home/ [:VIM_EVAL:]expand('%:p:h:t')[:END_EVAL:] | |||
home/home/ | |||
home/home/ Created by Yigit Colakoglu on [:VIM_EVAL:]strftime('%mhome/%dhome/%y')[:END_EVAL:]. | |||
home/home/ Copyright [:VIM_EVAL:]strftime('%Y')[:END_EVAL:]. Yigit Colakoglu. All rights reserved. | |||
home/home/ | |||
class Untitled { | |||
public static void main(String[] args) { | |||
} | |||
} |
@ -1,15 +0,0 @@ | |||
#!/bin/python | |||
# | |||
# [:VIM_EVAL:]expand('%:t')[:END_EVAL:] | |||
# [:VIM_EVAL:]expand('%:p:h:t')[:END_EVAL:] | |||
# | |||
# Created by Yigit Colakoglu on [:VIM_EVAL:]strftime('%m/%d/%y')[:END_EVAL:]. | |||
# Copyright [:VIM_EVAL:]strftime('%Y')[:END_EVAL:]. Yigit Colakoglu. All rights reserved. | |||
# | |||
def main(): | |||
print("hello world") | |||
if __name__ == "__main__": | |||
main() |
@ -1,2 +0,0 @@ | |||
#!/bin/sh | |||