Skip to content

bozenne/emacs-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My configuration for emacs

Installation

Emacs

The official installation guide for emacs can be found at https://www.gnu.org/software/emacs/download.html.

Note: windows user may find convenient to first install MSYS2 (https://www.msys2.org/) to have a linux-like interface, e.g. use pacman -S mingw-w64-x86_64-emacs to install emacs.

External dependencies

Linux: normally emacs should take care of installing all dependencies (otherwise you can do it yourself using list-packages). However you will need to install git yourself, e.g. using:

sudo apt update
sudo apt install git

as well as latex:

sudo apt-get install texlive-full
sudo apt-get install latexmk

and a pdf viewer like okular (https://okular.kde.org/) or sumatraPDF (https://www.sumatrapdfreader.org/free-pdf-reader).

Windows: you will need to install several additional software:

Link emacs to the proposed configuration

Basic version

Download all files and put them in a directory called emacs-config.

Place this directory in the folder containing the .emacs file (~/. when doing C-x C-f).

Copy the following code at the begining of the .emacs file:

;;; load automatic config
(package-initialize)
(setq user-full-name "my name")
(setq user-mail-adress "my.email@adress.com")
(setq path-emacs-config "~/emacs-config")
(setq path-emacs-snippet (concat path-emacs-config "/snippets"))

(load-file (expand-file-name "step01-load-packages.el" path-emacs-config))
(load-file (expand-file-name "step02-general-settings.el" path-emacs-config)) 
;;(load-file (expand-file-name "step03-email.el" path-emacs-config))
(load-file (expand-file-name "step04a-ess.el" path-emacs-config)) 
(load-file (expand-file-name "step04b-orgmode.el" path-emacs-config))
(load-file (expand-file-name "step04c-other-software.el" path-emacs-config))
(load-file (expand-file-name "step05-org-class.el" path-emacs-config))
(load-file (expand-file-name "step06-org-templates.el" path-emacs-config))
(load-file (expand-file-name "step07-header.el" path-emacs-config))
(load-file (expand-file-name "step08-folding.el" path-emacs-config))
(load-file (expand-file-name "step09-spellChecking.el" path-emacs-config))

(load-file (expand-file-name "FCT-dired.el" path-emacs-config))
(load-file (expand-file-name "FCT-editing.el" path-emacs-config))
(load-file (expand-file-name "FCT-file-management.el" path-emacs-config))
(load-file (expand-file-name "FCT-ess.el" path-emacs-config))
(load-file (expand-file-name "FCT-tex.el" path-emacs-config))
(load-file (expand-file-name "FCT-python.el" path-emacs-config))
(load-file (expand-file-name "FCT-org.el" path-emacs-config))
(load-file (expand-file-name "FCT-switch-to-OS-explorer.el" path-emacs-config))
(load-file (expand-file-name "FCT-superman.el" path-emacs-config))

(load-file (expand-file-name "step10-shorcuts.el" path-emacs-config))

In the first line, replace "my name" by your name. In the second line, replace "my.email@adress.com" by your email adress. In the third line, check that "~/emacs-config" is where you have put emacs-config.

Customization

Set the font size to 120 by adding the following line

;;; Font size
(set-face-attribute 'default nil :height 120)

Display the file ~/todo.org when starting emacs instead of the default emacs startup screen:

;;; File at startup
(setq inhibit-startup-screen t) ;; dismiss startup screen
(find-file "~/todo.org")

Remove the tool bar:

;;; remove tool bar
(tool-bar-mode -1)

Transfert to the agenda elements in ~/todo.org:

;;; Agenda
(setq org-agenda-files (list "~/todo.org")

Modifications for Windows

Add to the .emacs file something like:

;;; modification for windows

;;;; shell
;; https://www.gnu.org/software/emacs/manual/html_node/efaq-w32/Using-shell.html
(setq explicit-shell-file-name "c:/cygwin64/bin/bash")
(setq TeX-shell "c:/cygwin64/bin/bash")
(setq org-export-allow-bind-keywords t)

;; FROM: https://www.emacswiki.org/emacs/NTEmacsWithCygwin
(let* ((cygwin-root "c:/cygwin64")
       (cygwin-bin (concat cygwin-root "/bin")))
  (when (and (eq 'windows-nt system-type)
             (file-readable-p cygwin-root))

    (setq exec-path (cons cygwin-bin exec-path))
    (setenv "PATH" (concat cygwin-bin ";" (getenv "PATH")))

    ;; By default use the Windows HOME.
    ;; Otherwise, uncomment below to set a HOME
    ;;      (setenv "HOME" (concat cygwin-root "/home/eric"))

    ;; NT-emacs assumes a Windows shell. Change to bash.
    (setq shell-file-name "bash")
    (setenv "SHELL" shell-file-name) 
    (setq explicit-shell-file-name shell-file-name) 

    ;; This removes unsightly ^M characters that would otherwise
    ;; appear in the output of java applications.
    (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)))

;;;; path to external dependencies
(setq org-export-allow-bind-keywords t)

(setq TeX-view-program-list '(("SumatraPDF" "C://Users//hpl802//AppData//Local//SumatraPDF//SumatraPDF.exe %o")))
(setq TeX-view-program-selection '((output-pdf "SumatraPDF")
           			(output-dvi "Yap")))
(put 'overwrite-mode 'disabled nil)

;;;; update path variable
(setenv "PATH"
 	(concat
 	 "C:\\unison" ";"
 	 "C:\\hunspell" ";"
     "C:\\strawberry\\perl\\bin" ";"
 	 "C:\\Program Files\\SymatraPDF" ";" 	 
 	 "C:\\Program Files\\PuTTY" ";"
 	 "C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\" ";"
 	 (getenv "PATH")		;
 	 )
 	)

;;;; R software
(setq-default inferior-R-program-name "C:\\Program Files\\R\\R-4.1.1\\bin\\x64\\Rterm.exe")

;;;; spell checker
(setq ispell-program-name "hunspell")
(setq ispell-local-dictionary "en_GB")
;; (ispell-find-hunspell-dictionaries)

[Optional] Emails

WARNING: before trying anything, save all important emails outside the mailbox in case that the synchronisation does not work properly.

;;; send email

Receiving

Install offlineimap using sudo apt-get install offlineimap in the shell.

Then create a file ~/.offlineimaprc to indicate from which adress email should be imported:

[general]
accounts = Gmail
maxsyncaccounts = 3
pythonfile = ~/.offlineimap.py

[Account Gmail]
localrepository = localGmail
remoterepository = remoteGmail
autorefresh = 10

[Repository localGmail]
type = Maildir
localfolders = ~/Maildir/Gmail

[Repository remoteGmail]
type = Gmail
remoteuser = myadress@gmail.com
remotepasseval = get_password_emacs("imap.gmail.com", "myadress.com", "993")
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
auth_mechanisms = PLAIN
folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail', '[Gmail]/Starred', '[Gmail]/Important']
realdelete = no

For the password, create a file .offlineimap.py containing:

#!/usr/bin/python
import re, os

def get_password_emacs(machine, login, port):
    s = "machine %s login %s port %s password ([^ ]*)\n" % (machine, login, port)
    p = re.compile(s)
    authinfo = os.popen("gpg --quiet --passphrase anotherPassword --decrypt ~/.authinfo.gpg").read()#
#    authinfo = os.popen("gpg --quiet --no-tty --decrypt ~/.authinfo.gpg").read()
    return p.search(authinfo).group(1)

and a file ~/.authinfo.gpg containing:

machine imap.gmail.com login myadress@gmail.com port 993 password myGmailPassword
machine smtp.gmail.com login myadress@gmail.com port 587 password myGmailPassword

Then run offlineimap.

Then install mu using in the shell:

  • git clone https://github.com/djcb/mu.git
  • sudo apt-get install libtool
  • cd mu
  • mu/$ autoreconf -i && ./configure && make

Normally mu index should run and import emails.

Finally add to the ~/.emacs:

;;;; receive email
;; location of the mails
(setq mu4e-maildir (expand-file-name "~/Maildir"))

;; mail box
(setq mu4e-account-alist
      '(("Gmail"
         ;; Under each account, set the account-specific variables you want.
         (mu4e-sent-messages-behavior delete)
         (mu4e-sent-folder "/Gmail/[Gmail].Sent Mail")
         (mu4e-drafts-folder "/Gmail/[Gmail].Drafts")
         (mu4e-trash-folder "/Gmail/[Gmail].Trash")
         (user-mail-address "myadress@gmail.com")
         (user-full-name "My Name"))
       	)
      )

;; setup some handy shortcuts
(setq mu4e-maildir-shortcuts
      '(("/Gmail/INBOX" . ?i)
	("/Gmail/ProjectA" . ?a))
)

;; signature
(setq
 mu4e-compose-signature
 (concat
  "My Name \n"
  "myadress@gmail.com\n")
 )

Sending

Create a file ~/.authinfo.gpg to indicate from which adress emails can be sent:

machine imap.gmail.com login myadress@gmail.com port 993 password myGmailPassword
machine smtp.gmail.com login myadress@gmail.com port 587 password myGmailPassword

and add in the .emacs:

;;;; send email
(require 'smtpmail)

(setq message-send-mail-function 'smtpmail-send-it
     starttls-use-gnutls t
     smtpmail-starttls-credentials
     '(("smtp.gmail.com" 587 nil nil))
     smtpmail-auth-credentials
     (expand-file-name "~/.authinfo.gpg")
     smtpmail-default-smtp-server "smtp.gmail.com"
     smtpmail-smtp-server "smtp.gmail.com"
     smtpmail-smtp-service 587
     smtpmail-debug-info t)

Key binding

See the file extendedCommands.org

Credit

A major part of configuration comes from emacs-genome (thanks thomas!!!). In particular all the functions contained in the file FCT-superman.el are directly copied from emacs-genome.

About

My configuration for running emacs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published