An Emacs configuration to work with LaTeX, Python, C, C++, Pandoc, Markdown, Slack, and git running natively in different OS like MacOS, ArchLinux, and Ubuntu.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
7.6 KiB

;;; My basic configuration Gerardo Marx 20/May/2021
;; MacOS version
;;--------
;; Melpa repository:
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/")t)
(package-initialize)
;;+++++++++++++
;;function to check installed packages:
(defun is-installed (pack)
"Check if a package is istalled"
(unless (package-installed-p pack)
(package-refresh-contents)
(package-install pack)))
;;++++++++++++++++
;; use-package
(is-installed 'use-package)
(is-installed 'helm)
(require 'helm-config)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x r b") #'helm-filtered-bookmarks)
(global-set-key (kbd "C-x C-f") #'helm-find-files)
(helm-mode 1)
;;++++++++++++
;; which-key
(is-installed 'which-key)
(require 'which-key)
(which-key-mode)
;;+++++++++++++
;; frame size
;;(setq initial-frame-alist '((top . 325)(left . 0)
;; (width . 80)(height . 50)))
;; set transparency
(set-frame-parameter (selected-frame) 'alpha '(95 . 50))
(add-to-list 'default-frame-alist '(alpha . (95 . 50)))
;;+++++++++++
;; Doom-themes, all-the-icons, mode-line and font
(unless (package-installed-p 'doom-themes)
(package-install 'doom-themes))
(unless (package-installed-p 'all-the-icons)
(package-install 'all-the-icons))
(require 'doom-themes)
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each
;; theme may have their own settings.
(load-theme 'doom-one t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Enable custom neotree theme
(doom-themes-neotree-config) ; all-the-icons fonts must be installed!
;; Installling doom-modeline:
(unless (package-installed-p 'doom-modeline)
(package-install 'doom-modeline))
(require 'doom-modeline)
(doom-modeline-mode 1)
;;Intalling all-the-icons font:
(unless (package-installed-p 'all-the-icons)
(package-install 'all-the-icons))
;; Set default font:
(add-to-list 'default-frame-alist
'(font . "Source Code Pro-15"))
;;+++++++
;;auctex:
(is-installed 'auctex)
(is-installed 'pdf-tools);; PDFtools
(pdf-tools-install)
(setenv "PATH" (concat "/Library/TeX/texbin:"
(getenv "PATH")))
(add-to-list 'exec-path "/Library/TeX/texbin")
(setq TeX-auto-save t)
(setq TeX-save-query nil)
(setq LaTeX-includegraphics-read-file 'LaTeX-includegraphics-read-file-relative)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))
TeX-source-correlate-start-server t)
;; Update PDF buffers after successful LaTeX runs
(defun framesMenus-display-buffer-use-some-frame (fun &rest args)
"Use `display-buffer-use-some-frame' as `display-buffer-overriding-action'.
Then run FUN with ARGS."
(let ((display-buffer-overriding-action '(display-buffer-use-some-frame)))
(apply fun args)))
(advice-add 'TeX-pdf-tools-sync-view :around #'framesMenus-display-buffer-use-some-frame)
(advice-add 'pdf-sync-backward-search-mouse :around #'framesMenus-display-buffer-use-some-frame)
(add-hook 'TeX-after-compilation-finished-functions
#'TeX-revert-document-buffer)
(add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))
(add-hook 'pdf-view-mode-hook
(lambda () (pdf-tools-enable-minor-modes)))
(setq TeX-source-correlate-method 'synctex)
;;--end----
;;..............
;;========
;;Flyspell
(setq ispell-program-name "/usr/bin/aspell")
(dolist (hook '(text-mode-hook))
(add-hook hook (lambda () (flyspell-mode 1))))
;; ==========
;; ORG files:
(is-installed 'org-ref)
(require 'org-ref)
(setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))
(setq org-latex-prefer-user-labels t)
;; ==========
;; TRMAP
(eval-after-load 'tramp '(setenv "SHELL" "/bin/bash"))
;;=========
;;Shell
(setq-default explicit-shell-file-name "/bin/bash")
;; =========
;; markdown
(is-installed 'markdown-mode)
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(autoload 'gfm-mode "markdown-mode"
"Major mode for editing GitHub Flavored Markdown files" t)
(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
;; ========
;;Neotree
(is-installed 'neotree)
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)
;; ========
;; Python
;;=-=-=-=-=-=
;; Python completion:
(is-installed 'anaconda-mode)
(add-hook 'python-mode-hook 'anaconda-mode)
(add-hook 'python-mode-hook 'anaconda-eldoc-mode)
;(add-hook 'python-mode-hook 'jedi:setup)
;(setq jedi:complete-on-dot t) ; optional
;(setq jedi:environment-root "/usr/local/bin/python3")
;;=======
;; Python pyvenv
(is-installed 'pyvenv)
(pyvenv-mode t)
(setenv "WORKON_HOME" "~/.pyvenv/")
;(setq python-shell-interpreter (concat pyvenv-virtual-env "bin/python3"))
;(setq python-shell-interpreter "/usr/local/bin/python3")
;; -=-=-=-=-=-=-=-=-
;; My functions gmarx
;; Python chunk:
(defun python-shell-send-chunk ()
(interactive)
(save-excursion
(mark-paragraph)
(let ((start (region-beginning))
(end (region-end)))
(python-shell-send-region start end))
(keyboard-quit)))
;; my keybindings:
(global-set-key (kbd "C-c C-k") 'python-shell-send-chunk)
;;====================
;; emacs startup config
(setq inhibit-startup-message nil) ;;inhibit startup
(global-visual-line-mode t)
(tool-bar-mode -1)
(menu-bar-mode -1)
(global-hl-line-mode +1) ;; highlith current line
(delete-selection-mode +1) ;; deletes selected text and replace it
(scroll-bar-mode -1)
(setq ns-right-alternate-modifier nil) ;; right option macos key enable
(fset 'yes-or-no-p 'y-or-n-p) ;; Ask y/n instead of yes/no
(add-hook 'prog-mode-hook 'display-line-numbers-mode) ;; display line number when programming
(show-paren-mode +1) ;; show matching parentheses
;;---------
;; 2.6 ace-window
(is-installed 'ace-window)
(global-set-key (kbd "M-o") 'ace-window)
;; 2.7 avy
(is-installed 'avy)
(avy-setup-default)
(global-set-key (kbd "M-g f") 'avy-goto-line)
;; 2.8 multiple-cursors
(is-installed 'multiple-cursors)
(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(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.
'(custom-safe-themes
'("e19ac4ef0f028f503b1ccafa7c337021834ce0d1a2bca03fcebc1ef635776bea" "b0e446b48d03c5053af28908168262c3e5335dcad3317215d9fdeb8bac5bacf9" "4133d2d6553fe5af2ce3f24b7267af475b5e839069ba0e5c80416aa28913e89a" "fe2539ccf78f28c519541e37dc77115c6c7c2efcec18b970b16e4a4d2cd9891d" "4f1d2476c290eaa5d9ab9d13b60f2c0f1c8fa7703596fa91b235db7f99a9441b" default))
'(package-selected-packages
'(multiple-cursors ace-window which-key use-package pyvenv pdf-tools org-ref neotree markdown-mode jedi helm doom-themes doom-modeline docker-compose-mode auctex anaconda-mode)))
(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.
)