summaryrefslogtreecommitdiffstats
path: root/roles/obs/tasks/emacs.yml
blob: 0b013b344728e8be6120ecb60188b250aef2d4df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
- name: Check out emacsconf-el
  ansible.builtin.git:
    repo: https://git.emacsconf.org/emacsconf-el
    dest: "~{{ emacsconf_user }}/emacsconf-el"
  register: elisp
  failed_when:
    - elisp.failed
    - not 'Local modifications exist in repository' in elisp.msg
    - not 'Failed to checkout branch' in elisp.msg
  debugger: on_failed
- name: Install Emacs packages
  become_user: "{{ emacsconf_user }}"
  shell: |
    emacs --batch --exec "(progn (require 'package)
      (let ((packages (seq-remove #'package-installed-p '({% for package in packages %}{{ package }} {% endfor %}))))
        (when packages
           (package-refresh-contents)
           (mapc #'package-install packages))))"
  vars:
    packages:
      - modus-themes
      - vertico
      - orderless
- name: Set up Emacs configuration for interactive editing
  template:
    src: emacsconf-stream-config.el
    dest: "{{ emacs_config_dir }}/emacsconf-stream-config.el"
    owner: "{{ emacsconf_user }}"
    group: "{{ emacsconf_group }}"
- name: Add to Emacs configuration
  lineinfile:
    dest: "{{ emacs_config_dir }}/init.el"
    state: present
    regexp: "emacsconf-stream-config"
    line: "(load-file \"{{ emacs_config_dir }}/emacsconf-stream-config.el\")"
    owner: "{{ emacsconf_user }}"
    group: "{{ emacsconf_group }}"
    create: yes