(defunig/async-process (command&optionalnamefilter)
"Start an async process by running the COMMAND string with bash. Return theprocess object for it.NAME is name for the process. Default is \"async-process\".FILTER is function that runs after the process is finished, its args should be\"(process output)\". Default is just messages the output."
(make-process:command `("bash""-c",command)
:name (if name name
"async-process")
:filter (if filter filter
(lambda (processoutput) (message (s-trim output))))))
(defunig/add-local-hook (hookfunction)
"Add buffer-local hook."
(add-hook hook function :localt))
(defunig/tangle-config ()
"Export code blocks from the literate config file asynchronously."
(interactive)
;; prevent emacs from killing until tangle-process finished
(add-to-list'kill-emacs-query-functions
(lambda ()
(or (not (process-live-p (get-process"tangle-process")))
(y-or-n-p"\"ig/tangle-config\" is running; kill it? "))))
;; tangle config asynchronously
(ig/async-process
(format"emacs %s --batch --eval '(org-babel-tangle nil \"%s\")'" config-org config-el)
"tangle-process"))
(add-hook'org-mode-hook
(lambda ()
(if (equal buffer-file-truename config-org)
(ig/add-local-hook 'after-save-hook'ig/tangle-config))))
(add-to-list'default-frame-alist '(undecorated .t))
(setq straight-check-for-modifications '(check-on-save find-when-checking))
;; Set the threshold to very high to not garbage collect
(setq gc-cons-threshold most-positive-fixnum)
;; Restore `gc-cons-threshold' to a reasonable value after init
(add-hook'emacs-startup-hook; Hook that runs after init files are loaded
(lambda ()
;; Set a reasonable value that won't hang Emacs or won't increase ram usage
(setq gc-cons-threshold (*5010001000)))
100) ; Make sure this function will run at the end of `emacs-startup-hook's.
General
;; To keep folders clean
(use-package no-littering)
(setq create-lockfiles nil)
(setq user-full-name "Seyyid İbrahim Güleç"
user-mail-address "seyyidibrahimgulec@gmail.com")
(setq inhibit-startup-message t) ; Don't show the splash screen
(setq ring-bell-function 'ignore) ; prevent beep sound.
(setq require-final-newline t) ; Add new line end of the file
(setq truncate-lines t)
(setq-default fill-column 80
sentence-end-double-space nil
indent-tabs-mode nil; Use spaces instead of tabs
tab-width 4)
;; Modes
(global-display-line-numbers-mode-1)
(column-number-mode1)
(menu-bar-mode-1)
(tool-bar-mode-1)
(scroll-bar-mode-1)
(global-hl-line-mode1)
(global-auto-revert-mode1)
(blink-cursor-mode-1)
(delete-selection-mode1)
(electric-pair-mode-1)
;; (pixel-scroll-precision-mode 1)
(setq global-auto-revert-non-file-buffers t)
;; (recentf-mode 1);; (savehist-mode 1);; (setq history-length 25);; (save-place-mode 1);; Move custom variables to seperate file
(setq custom-file (locate-user-emacs-file"custom-vars.el"))
(load custom-file 'noerror'nomessage)
;; Make sure to focus when a new emacsclient frame created.
(add-hook'server-after-make-frame-hook (lambda () (select-frame-set-input-focus (selected-frame))))
;; Macos Key Bindings;; (setq mac-option-key-is-meta nil;; mac-command-key-is-meta t;; mac-command-modifier 'meta;; mac-option-modifier 'none)
(defunkill-all-buffers ()
"Kill all buffers."
(interactive)
(mapc'kill-buffer (buffer-list)))
(defunig/display-startup-time ()
(message"Emacs loaded in %s with %d garbage collections."
(format"%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done))
(add-hook'emacs-startup-hook#'ig/display-startup-time)
(defunig/open-emacs-configuration ()
(interactive)
(find-file"~/.emacs.d/README.org"))
(defunig/open-dotfiles-configuration ()
(interactive)
(find-file"~/README.org"))
(global-set-key (kbd"M-o e") 'ig/open-emacs-configuration)
(global-set-key (kbd"M-o d") 'ig/open-dotfiles-configuration)
(use-package rg
:defert)
(use-package simple-httpd
:ensuret)
;; Some Extra Keybindings;; source: spacemacs' better default layer
(defunbackward-kill-word-or-region ()
"Calls `kill-region' when a region is active and`backward-kill-word' otherwise."
(interactive)
(if (region-active-p)
(call-interactively'kill-region)
(backward-kill-word1)))
(global-set-key (kbd"C-w") 'backward-kill-word-or-region)
;; Use shell-like backspace C-h, rebind help to C-?
(keyboard-translate?\C-h ?\C-?);; Fix emacs daemon
(add-hook'server-after-make-frame-hook (lambda () (keyboard-translate?\C-h ?\C-?)))
(global-set-key (kbd"C-?") 'help-command)