File: emacs.txt

package info (click to toggle)
modules 5.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,036 kB
  • sloc: exp: 79,659; sh: 6,142; tcl: 5,900; makefile: 1,493; ansic: 474; python: 265; csh: 202; perl: 47; ruby: 44; lisp: 13
file content (68 lines) | stat: -rwxr-xr-x 2,114 bytes parent folder | download | duplicates (5)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Submitted by tbennett@nvidia.com, Nov 18, 2004


How to init emacs lisp modules from .emacs:

    ;; load and init emacs lisp modules if not already loaded...
    (if (and (getenv "MODULESHOME")
             (file-directory-p (getenv "MODULESHOME"))
             (not (fboundp 'module)))
        (progn
          (if (load-file (concat (getenv "MODULESHOME") "/init/lisp"))
              (define-key global-map "\C-cm" 'Modules-module))))

After this, from within your emacs process you can run any module
command, eg:

    C-c m load modules
    C-c m list
    etc.


What follows describes an optional usage.

Since I use env variables frequently within emacs (mostly to
specify filename paths) and also use shell-mode, I want to have
all modules commands run within both emacs and in my *shell*
buffer.  The following works for me, but may need tweaking in
other environments...

    ;; send a cmd to my shell
    ;; not very flexible, knows about my setup, shell, etc.
    ;; cribbed from switch-to-shell.el

    (defvar my-shell-command-shell-buffer-name "*shell*"
      "The name of the shell buffer.")

    (defun my-shell-command (command)
      (interactive "sCommand: ")
      ;; Find shell buffer
      (and (get-buffer my-shell-command-shell-buffer-name)
           (pop-to-buffer my-shell-command-shell-buffer-name)
           (get-buffer-process (current-buffer))
           (progn
             (goto-char (point-max))
             (comint-kill-input)          ;; delete any junk on line
             (insert-string command)
             (comint-send-input))))

    ;; send the same module cmd to both emacs and my shell buffer
    (defun m-doit (cmd)
      (and (Modules-module cmd)
           (my-shell-command (concat "module " cmd))))

    ;; a sample module command using above
    (defun m-projects-A ()
       (interactive)
       (m-doit "unload projects") 
       (m-doit "load projects/A"))
    (defun m-projects-B ()
       (interactive)
       (m-doit "unload projects") 
       (m-doit "load projects/B"))

    Then use

        M-x m-projects-A <RET>

    to switch to project-A setup.