summaryrefslogtreecommitdiffstats
path: root/roles/edit/tasks/main.yml
blob: 9419f92247dacfcdcba830213e24a8ae20b1c188 (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
40
41
42
43
44
45
---
- name: Check if Emacs is already set up for publishing
  stat:
    path: "{{ emacs_config_dir }}/emacsconf-config.el"
  register: publish_config
- name: Set up for publishing
  include_role:
    name: publish
  when: not publish_config.stat.exists
- name: Install Emacs packages
  shell: |
    emacs --batch --exec "(progn (require 'package)
      (let ((packages (seq-remove #'package-installed-p '({% for package in emacsconf_edit_packages %}{{ package }} {% endfor %}))))
        (when packages
           (package-refresh-contents)
           (mapc #'package-install packages))))"
- name: Add alias for Emacsconf
  lineinfile:
    line: alias emacsconf="emacsclient -c -a emacs"
    dest: "~{{ emacsconf_user }}/.bashrc"
    owner: "{{ emacsconf_user }}"
    group: "{{ emacsconf_group }}"
    create: yes
- name: Set timezone
  lineinfile:
    line: export TZ={{ emacsconf_timezone }}
    dest: "~{{ emacsconf_user }}/.bashrc"
    owner: "{{ emacsconf_user }}"
    group: "{{ emacsconf_group }}"
    create: yes
- name: Set up Emacs configuration for interactive editing
  template:
    src: emacsconf-edit.el
    dest: "{{ emacs_config_dir }}/emacsconf-edit.el"
    owner: "{{ emacsconf_user }}"
    group: "{{ emacsconf_group }}"
- name: Check if Emacs base configuration already exists
  lineinfile:
    dest: "{{ emacs_config_dir }}/init.el"
    state: present
    regexp: "emacsconf-edit"
    line: "(load-file \"{{ emacs_config_dir }}/emacsconf-edit.el\")"
    owner: "{{ emacsconf_user }}"
    group: "{{ emacsconf_group }}"
    create: yes