CSRaghunandan / .emacs.d

My emacs configuration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rag .emacs.d

My emacs config.

Dependencies needed for compiling emacs28 from source

Below are the dependencies needed to compile emacs from source:

  • automake, gcc, make: to build Emacs from source
  • imagemagick7: for imagemagick integration
  • librsvg: for rendering SVG files in emacs
  • mailutils: for mailutils integration in emacs
  • gnutls: for security
  • gtk3: library for Gtk3
  • dbus: library for integration of dbus with emacs
  • texinfo: needed for documentation
  • libpng, libjpeg, libxpm, giflib, libtiff: media dependencies

Optional dependencies for running my emacs configuration

These are optional, but will definitely improve the experience for using emacs. I recommend installing all the below tools:

  • CMake: needed for vterm.el package
  • libvterm: needed for vterm.el package
  • watchexec: needed for watching for file changes for packages and running build to update the packages. This is needed for straight.el
  • direnv: for getting direnv integration with Emacs
  • ripgrep: for faster search integration in Emacs
  • fd: integrate fd into emacs for faster file searches
  • poppler: PDF rendering library. Needed for pdf-tools

Installing and configuring Emacs

  • Install Emacs28 from source by running:
    git clone --depth 1 master https://github.com/emacs-mirror/emacs
    cd emacs
    sh autogen.sh
    ./configure --with-modules --with-rsvg --with-dbus \
         --without-pop --with-xft --with-xml2 --with-libotf --with-mailutils \
         --without-toolkit-scroll-bars --without-xaw3d \
          CFLAGS="-O3 -mtune=native -march=native -fomit-frame-pointer"
    # replce -jX, X is the number of cores in your machine
    make -j8
    make install
        
    • Optionally, you can also compile emacs native compilation branch, like so
      git clone --depth 1 master https://github.com/emacs-mirror/emacs -b feature/native-comp
      cd emacs
      sh autogen.sh
      ./configure --with-modules --with-rsvg --with-dbus \
           --without-pop --with-xft --with-xml2 --with-libotf --with-mailutils \
           --with-nativecomp --without-toolkit-scroll-bars --without-xaw3d \
            CFLAGS="-O3 -mtune=native -march=native -fomit-frame-pointer"
      # replce -jX, X is the number of cores in your machine
      make -j8
      make install  
              
      • Add the below line to early-init.el
        ;; comment out this line if you are not using emacs native compilation branch
        ;; native compile elisp files as they are loaded
        (setq comp-deferred-compilation t)
                    
    • Enable and run the systemd service for emacs:
      systemctl --user enable emacs --now
              
    • Change the emacs.desktop file to launch emacsclient, its located in /usr/local/share/applications/emacs.desktop:
      [Desktop Entry]
      Name=Emacs
      GenericName=Text Editor
      Comment=Edit text
      MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
      Exec=/usr/local/bin/emacsclient -c -a '' %F
      Icon=emacs
      Type=Application
      Terminal=false
      Categories=Development;TextEditor;
      StartupWMClass=Emacs
      Keywords=Text;Editor;
              
    • Make emacs your default text editor by adding the below lines to your .zshenv file:
      export EDITOR="emacsclient -n -a \"\""
      export VISUAL="emacsclient -n -a \"\""
              
    • Setup handy aliases for emacs by adding the below in your .aliases file:
      alias ec='emacsclient -nc -a ""'
      alias eg='emacsclient -n -a ""'
      alias et='TERM=xterm-256color emacsclient -t -a ""'
              
      • Now you can open emacs by conecting to the emacs daemon using emacsclient using: ec
      • You can open a file on the existing emacs frame by: eg file-name
      • Emacs configuration for vterm integration:
        function vterm_printf() {
        	if [ -n "$TMUX" ]; then
        		# tell tmux to pass the escape sequences through
        		# (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324)
        		printf "\ePtmux;\e\e]%s\007\e\\" "$1"
        	elif [ "${TERM%%-*}" = "screen" ]; then
        		# GNU screen (screen, screen-256color, screen-256color-bce)
        		printf "\eP\e]%s\007\e\\" "$1"
        	else
        		printf "\e]%s\e\\" "$1"
        	fi
        }
        
        if [ -n "$INSIDE_EMACS" ]; then
        	vterm_prompt_end() {
        		vterm_printf "51;A$(whoami)@$(hostname):$(pwd)"
        	}
        	PROMPT=$PROMPT'%{$(vterm_prompt_end)%}'
        fi
        
        if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
        	alias clear='vterm_printf "51;Evterm-clear-scrollback";tput clear'
        fi
          
                    

Notes

  • Ivy as the preferred completion frontend for emacs.
  • Very minimal theme with no toolbar, no scrollbars, no line numbers and use Nord theme.
  • Tested to work with Emacs 27 and Emacs 28 on Linux and MacOS.

About

My emacs configuration

License:MIT License


Languages

Language:Emacs Lisp 99.9%Language:YASnippet 0.1%