There are many way to do that.
(.emacs)
When you start up the emacs (without -q
option),
emacs usually read .emacs
file. (some xemacs uses
.xemacs/init.el). Then you can just copy and paste
functions in it. But this is a little bit cumbersome.
The function autoload
load elisp (Emacs Lisp) file
dynamically. Dynamically means it will not be loaded unless you
really use. But you should give some information to the emacs:
(autoload 'e-function "elisp-file" "" t nil)
tells to the emacs that when the e-function called, emacs
should read the file elisp-file.
But how the emacs find the elisp-file?
For example, you put your elisp file somewhere, how can the emacs
find that? It can not be to search whole your filesystem.
The emacs find files using the load-path
variable.
This is a kind of PATH variable in shell.
So you add your path to the load-path
, set
autoload
, then the emacs find a mapping of
command/function and elisp file. Adding your path to
load-path
is done by next in your .emacs
file:
;; ;; load path ;; (setq load-path (append (list "/your/emacs/lisp/files/under/this/directory" ) load-path))
Next small program may help you. changeh2c.el
Setting up:
;; ;; changeh2c : change .hh and .C file with one command ;; (autoload 'changeh2c "changeh2c" "change .hh and .C file with one command" t nil)
(global-set-key 'f8 'changeh2c)
(defun my-cpp-mode-common-hook () (progn (local-set-key 'f8 'changeh2c) )) (add-hook 'c-mode-common-hook 'my-cpp-mode-common-hook)
Sometimes, you may want to jump especially file from a file.
For this purpose this elisp accept a local variable
changeh2c-other-file
.
Ex. in some html mode (here example is yahtml, jump from index.html to index-j.html.
<!-- Local Variables: *** --> <!-- mode:yahtml *** --> <!-- changeh2c-other-file:"index-j.html" *** --> <!-- End: *** -->
changeh2c is confused by the situation with one suffix may include a part of other suffix. For example, assume there are 'a-j-j.html a-j.html, a.html' files and suffixes '-j.html, .html'. Your buffer has a-j.html. Then which suffix should be matched? And which file should be selected to the destination to jump. You can make a rule for this and also you can remember each buffer's find-file history to avoid to jump yourself. But, I think this implementation is not to worth.
However, I have files index.html and index-j.html. More precisely, I should name these as index-e.html (English) and index-j.html (Japanese). But, some web server's settings do not accept the index-e.html as the default file. Then, some specified file jump is needed.
Next small program may help you. wc.el
Setting up:
;; ;; wc.el (word counter) ;; (autoload 'count-chars-region "wc" nil t)
M-x count-chars-region
.
Next small program may help you. where.el
Setting up:
;; ;; where ;; (autoload 'where-is-in "where" "where *.el" t)
M-x where-is-in
.
Then input which filename do you want. ex. where.el
Next small program may help you. replace-zen-to-ascii-region.el
Setting up:
;; ;; replace zenkaku -> ascii region ;; (autoload 'replace-zen-to-ascii-region "replace-zen-to-ascii-region" nil t)
M-x replace-zen-to-ascii-region
.
Around app-defaults directory, ja/Emacs or something similar file exists. Usually, this Xresource file is read according to LANG or LC_ALL. However, some (Japanese) distribution seems hard coded this environment variable somewhere. In such case, you can put LANG as de or fr, if you are OK. Or, change the Xdefaults according to this app-defaults file.