Skip to content

ChristianGeng/emacs-conf

Repository files navigation

README

Doom Flavor

doom has got an environment file:

doom help env

To get started I am using this:

git clone https://github.com/hlissner/doom-emacs-private ~/.config/doom

Building Emacs

Directory Structure

Following a clean, organized directory structure:

~/local/                      # Base directory for local software
├── src/                      # Source code for software to be compiled
│   ├── emacs/                # Emacs source code
│   ├── texinfo/              # Texinfo source code
│   └── ...
├── build/                    # Build directories (keeps source dir clean)
│   ├── emacs/                # Emacs build directory
│   ├── texinfo/              # Texinfo build directory
│   └── ...
├── opt/                      # Installed software (similar to /opt)
│   ├── emacs/                # Emacs installation
│   ├── texinfo/              # Texinfo installation
│   └── ...
├── bin/                      # Symlinks to installed binaries
├── lib/                      # Libraries for local software
├── include/                  # Header files for local software
├── share/                    # Shared data files
├── var/                      # Variable data (logs, etc.)
└── etc/                      # Configuration files

Local Build

# Create necessary directories
mkdir -p ~/local/{src,build,opt,bin,lib,include,share,var,etc}

# Get Emacs source code
cd ~/local/src
git clone https://git.savannah.gnu.org/git/emacs.git
cd emacs

# Create and use build directory
mkdir -p ~/local/build/emacs
cd ~/local/build/emacs

# Generate configuration files
~/local/src/emacs/autogen.sh
# Configure with appropriate paths
CPPFLAGS="-I$HOME/local/include" \
LDFLAGS="-L$HOME/local/lib" \
LIBS="-lgif" \
~/local/src/emacs/configure \
  --prefix=$HOME/local/opt/emacs \
  --bindir=$HOME/local/bin \
  --with-native-compilation \
  --with-mailutils \
  --with-tiff=ifavailable \
  --with-gnutls=ifavailable \
  --with-gif \
  CPPFLAGS="-I$HOME/local/include" \
  LDFLAGS="-L$HOME/local/lib"

# Build and install
make -j$(nproc)
make install

# Add to PATH if not already there
echo 'export PATH="$HOME/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

    # Create necessary directories
    mkdir -p ~/local/{src,build,opt,bin,lib,include,share,var,etc}

    # Get Emacs source code
    cd ~/local/src
    git clone https://git.savannah.gnu.org/git/emacs.git
    cd emacs

    # Build in the source directory (not in a separate build directory)
    # Run the autogen script
    ./autogen.sh

    # Configure with appropriate paths
    ./configure \
      --prefix=$HOME/local/opt/emacs \
      --bindir=$HOME/local/bin \
      --datarootdir=$HOME/local/share \
      --libdir=$HOME/local/lib \
      --infodir=$HOME/local/share/info \
      --mandir=$HOME/local/share/man \
      --with-native-compilation \
      --with-mailutils \
      --with-tiff=ifavailable \
      --with-gnutls=ifavailable \
      --with-x-toolkit=no \
      --without-native-compilation \
      --with-xpm=ifavailable \
      --with-gif=ifavailable

    # Build and install
    make -j$(nproc)
    make install

    # Add to PATH if not already there
    echo 'export PATH="$HOME/local/bin:$PATH"' >> ~/.bashrc
    source ~/.bashrc

Note:

CPPFLAGS="-I$HOME/local/include"
LDFLAGS="-L$HOME/local/lib"

should result in the config lines having lines like this

GIF_CFLAGS='-I/fsx/christian.geng/local/include'
LIBGIF='-L/fsx/christian.geng/local/lib -lgif'

Clean Build Instructions

If you need to rebuild Emacs (or any software) from scratch, it’s best to start with a clean build directory to avoid stale configuration or object files. This is especially important when changing dependencies like giflib, gnutls, etc.

# Remove the existing build directory (be careful: this deletes all build artifacts)
rm -rf ~/local/build/emacs

# Recreate and enter the build directory
mkdir -p ~/local/build/emacs
cd ~/local/build/emacs

# Run configure with the appropriate flags
~/local/src/emacs/configure \
  --prefix=$HOME/local/opt/emacs \
  --bindir=$HOME/local/bin \
  --with-native-compilation \
  --with-mailutils \
  --with-tiff=ifavailable \
  --with-gnutls=ifavailable \
  --with-gif \
  CPPFLAGS="-I$HOME/local/include" \
  LDFLAGS="-L$HOME/local/lib"

# Build and install
make -j$(nproc)
make install

This ensures that your build picks up any changes to libraries or headers.

Building Texinfo

Texinfo is required for building Emacs. If your system’s texinfo is missing or outdated, you can build it from source:

# Navigate to source directory
cd ~/local/src

# Download texinfo source
wget https://ftp.gnu.org/gnu/texinfo/texinfo-6.8.tar.gz
tar xzf texinfo-6.8.tar.gz

# Create and use build directory
mkdir -p ~/local/build/texinfo
cd ~/local/build/texinfo

# Configure with appropriate paths
~/local/src/texinfo-6.8/configure --prefix=$HOME/local/opt/texinfo --bindir=$HOME/local/bin

# Build and install
make
make install

# Verify installation   
which makeinfo
makeinfo --version

Tip: Do you need to run autoreconf?

  • If you download a release tarball (e.g., texinfo-6.8.tar.gz, giflib-5.2.1.tar.gz), the configure script is already present and ready to use. You do NOT need to run autoreconf; just run ./configure in your build directory.
  • If you clone from git or use a development source tree, the configure script may be missing or outdated. In that case, run autoreconf -i (or autogen.sh, if present) before ./configure.

You can then use the locally installed texinfo when building Emacs by ensuring it’s in your PATH:

# When configuring Emacs, ensure the local bin directory is in your PATH
export PATH="$HOME/local/bin:$PATH"

# Or, if you prefer, explicitly set the MAKEINFO variable



** GnuTLS

You can build gnutls from source:

cd ~/local/src
wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.8/gnutls-3.8.0.tar.xz
tar -xf gnutls-3.8.0.tar.xz
cd gnutls-3.8.0

autoreconf -i
automake

./configure --prefix=$HOME/local/opt/gnutls --bindir=$HOME/local/bin
make
make install


** GIFLIB

You can build giflib from source:

# Download giflib source
cd ~/local/src
wget https://downloads.sourceforge.net/project/giflib/giflib-5.2.1.tar.gz

# Extract and enter source directory
 tar xzf giflib-5.2.1.tar.gz
cd giflib-5.2.1

# Build and install (giflib uses in-tree build)
make
make install PREFIX=$HOME/local/opt/giflib

# Ensure your local lib/include directories contain giflib files
cp $HOME/local/opt/giflib/lib/libgif.* $HOME/local/lib/
cp $HOME/local/opt/giflib/include/gif_lib.h $HOME/local/include/

# (Optional) Check that the header and library are present
ls -l $HOME/local/include/gif_lib.h
ls -l $HOME/local/lib/libgif*

Note: giflib does not provide a pkg-config file, so you must use CPPFLAGS and LDFLAGS to help Emacs’ configure script find giflib. For example:

CPPFLAGS="-I$HOME/local/include" LDFLAGS="-L$HOME/local/lib" ./configure --prefix=$HOME/local/opt/emacs --bindir=$HOME/local/bin --with-gif --with-other-flags

Refer to the GIFLIB section below for details.

Nettle

You can build nettle from source:

cd ~/local/src wget ftp://ftp.gnu.org/gnu/nettle/nettle-3.8.1.tar.gz tar xzf nettle-3.8.1.tar.gz cd nettle-3.8.1

./configure –prefix=$HOME/local/opt/nettle –bindir=$HOME/local/bin make make install

Dependencies

sudo apt-get install -y \
  gcc-10 libgccjit0 libgccjit-10-dev \
  libjansson4 libjansson-dev git \
  software-properties-common \
  automake texinfo

Docker Build

# Navigate to Emacs source directory
cd ~/local/src/emacs

# Create a Dockerfile
cat > Dockerfile << 'EOF'
FROM ubuntu:20.04

# Install dependencies
RUN apt-get update && apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common \
    gcc-10 libgccjit0 libgccjit-10-dev \
    libjansson4 libjansson-dev git \
    automake texinfo

# Add GCC repository for native compilation
RUN add-apt-repository ppa:ubuntu-toolchain-r/ppa \
    && apt-get update

# Get Emacs build dependencies
RUN apt-get build-dep -y emacs

# Set compiler for native compilation
ENV CC="gcc-10"

# Copy source code
COPY . /opt/emacs
WORKDIR /opt/emacs

# Build Emacs
RUN ./autogen.sh \
    && ./configure --with-native-compilation --with-mailutils \
    && make -j$(nproc) \
    && make install

ENTRYPOINT ["emacs"]
EOF

# Build the Docker image
docker build -t emacs-build .

# Run Emacs in Docker
docker run -it --rm emacs-build

Important Configure Flags

  • –prefix=$HOME/local/opt/emacs: Sets installation directory
  • –bindir=$HOME/local/bin: Where executable binaries will be installed
  • –datarootdir=$HOME/local/share: Directory for read-only architecture-independent data
  • –libdir=$HOME/local/lib: Directory for libraries
  • –infodir=$HOME/local/share/info: Directory for info documentation
  • –mandir=$HOME/local/share/man: Directory for man pages
  • –with-native-compilation: Enable native compilation support (faster Elisp)
  • –with-mailutils: Include mail utilities
  • –with-tiff=ifavailable: Include TIFF support if available
  • –with-gnutls=ifavailable: Include GnuTLS support if available
  • –without-x: Build without X Window System support (optional, for terminal-only use)

Troubleshooting

Permission Errors

If you encounter permission errors like:

umask 022; /usr/bin/mkdir -p "/usr/local/share/info"
/usr/bin/mkdir: cannot create directory '/usr/local/share/info': Permission denied
make: *** [Makefile:793: install-info] Error 1

Make sure that all installation paths in the configure step are set to locations within your home directory. The key flags to check are:

  • –prefix
  • –datarootdir
  • –infodir
  • –mandir
  • –libdir

Using directories under ~/local/ should resolve these permission issues.

Purpose / General Links

My adapation of https://github.com/chaoflow/.emacs.d

Original README:

Be prepared for rebases.

Better take a look at other sources for configuration files:

Languages / Modes

C/C++

Org mode

Capturing

  • C-c c - Capturn

Links für Capturing Templates

Lisp

  1. Learn Emacs Lips the Hard Way
  2. Emacs Lisp caiorss
  3. Elisp versus Scheme Lisp keywords
  4. Learn Elisp the hard way

Python

- Anleitung für pep mode hook

LSP and Python

Java IDE

http://www.goldsborough.me/emacs,/java/2016/02/24/22-54-16-setting\_up\_emacs\_for\_java\_development/ http://www.skybert.net/emacs/java/ https://github.com/skybert/my-little-friends/blob/master/emacs/.emacs.d/tkj-java-meghanada.el https://github.com/skybert/my-little-friends/blob/master/emacs/.emacs.d/tkj-java-meghanada.el

Web Development

Currently used Major Modes - mmm mode are two multi-mode enginges web mode. I have mainly configured - vue-mode for vue framework files - js2-mode for javascript

Important Minor Modes

emmet mode

Completion for css, js, html. Abbreviations on homepage,

https://github.com/smihica/emmet-mode

C-j

Company-web

Company backend for web completion https://github.com/osv/company-web configured in setup-web-mode.el and setup-auto-complete.el

M-x company-web-html

see this for language server alternative https://emacs.stackexchange.com/questions/55230/help-setting-up-company-mode-autocompletion-of-html-css-files

Web Mode -> Major Mode for mainly Templates, html

Flycheck use eslint: http://codewinds.com/blog/2015-04-02-emacs-flycheck-eslint-jsx.html

C-c C-f web-mode-fold-or-unfold C-c C-e i web-mode-element-insert C-c C-s insert snippets M-; comment out regions C-c C-w show whitespaces C-c C-m mark region

Selection Expansion C-n marks current element

Tag Navigation:

Closing element : type ‘</’ and it happens in html similarly for templates

Type faster: emmet-mode: But web-mode has sth similar d/ -> creates div, /s creates spna

Vue Mode

  • To be described - Using lsp is quite cool

Web Development further links:

LSP und DAP

Other Topics

Helm

  1. A Package in a league of its own
  2. helm-wiki
  3. bloc post
  4. helm-swoop

Fill column indication

  • start using fci-mode
  • (setq fci-rule-column 100)

Code Navigation usig Etags

Etags Navigation

etags primer

  • find . -name '*.[ch]' | xargs etags
  • M-. (that’s Meta-Period) and type the name of the function
  • M-* to navigate to last point
  • Use helm to navigate to tags: M-x helm-etags-select
  • Use projectile-regenerate-tags to generate tags before.

.dir-locals

(
 (nil . (
         (projectile-project-test-cmd . "pytest --color=yes app/  --ignore app/tests/  --cov=app/study --cov=app/report  --cov=app/core")
         ;; (compilation-read-command . nil)
         (py-pythonpath . "/home/audeering.local/cgeng/code/data_collection/aisoundlab/backend/app/")
         ;; (setq venv-dirlookup-names '(".projectile" ".venv" "pyenv" ".virtual"))
         ;; Automatically activating a virtualenv when using projectile
         ;; (setq projectile-switch-project-action 'venv-projectile-auto-workon)
         (eval . (progn
          (make-local-variable 'process-environment)
          (setq process-environment (copy-sequence process-environment))
          (setenv "PYTHONPATH" "/home/cgeng/code/app/:/home/cgeng/some_dir/")
          (setenv "WORKON_HOME" (expand-file-name "~/work/.envs"))
          ))
         )
  )
 (python-mode . (
                 ;; (pyvenv-activate . "~/.venvs/py37")
                 (lsp-pyright-venv-path . "~/.venvs/")
                 (subdirs . nil))
              )

)

Links

Lern use-package and stream the configurations: https://github.com/jwiegley/use-package

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published