emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Oleh <ohwoeowho@gmail.com>
To: Rainer M Krug <Rainer@krugs.de>
Cc: Org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: Moving my init.el to Org
Date: Wed, 3 Sep 2014 13:17:00 +0200	[thread overview]
Message-ID: <CAA01p3qx=s0Obxc7cchKcLGj0osKgkBadN66AUPk_NNmi8w8TA@mail.gmail.com> (raw)
In-Reply-To: <m21trucs6i.fsf@krugs.de>

>> I'm using a one .el file per mode approach, with around 4000 lines
>> split into 40 files.
>>
>> This approach simplifies things a lot: for instance I haven't touched
>> Javascript in ages, but all my customizations for it are sitting in
>> javascript.el without getting in the way of the stuff that I'm using
>> now. They aren't even loaded unless I open a js file.
>
> Interesting - is your configuration online, so that one could take a
> look at it? I did not find them on your github page?

It's not online since it's a hassle to put it up.

> Or how do you do it, that the e.g. javascript.el is only loaded when a
> js file is opened? Because this is exactly what I would like to have.

It's a three-part setup that goes like this.
In hooks.el that's loaded unconditionally:

    ...
    (add-hook 'java-mode-hook 'oleh-java-hook)
    (add-hook 'tuareg-mode-hook 'oleh-tuareg-hook)
    (add-hook 'js-mode-hook 'oleh-javascript-hook)
    (add-hook 'markdown-mode-hook 'oleh-markdown-hook)
    ...

In modes/javascript.el that's not loaded:

    ;;;###autoload
    (defun oleh-javascript-hook ()
      (smart-insert-operator-hook)
      (moz-minor-mode 1)
      (define-key js-mode-map (kbd "<f5>") 'js-f5)
      (define-key js-mode-map (kbd "C-<f5>") 'js-C-f5)
      ...
      )

And this function generates the autoloads when a new file is added:

    ;;;###autoload
    (defun update-all-autoloads ()
      (interactive)
      (let ((generated-autoload-file (concat emacs.d "loaddefs.el")))
        (when (not (file-exists-p generated-autoload-file))
          (with-current-buffer (find-file-noselect generated-autoload-file)
            (insert ";;") ;; create the file with non-zero size to
appease autoload
            (save-buffer)))
        (mapcar #'update-directory-autoloads
                '("" "oleh" "oleh/modes" "matlab-emacs"))))

The file loaddefs.el is loaded unconditionally as well.  So when a js
file is opened, `js-mode-hook` is called and the autoloaded
`oleh-javascript-hook` is called, making sure that
"oleh/modes/javascript.el" is loaded.

regards,
Oleh

  parent reply	other threads:[~2014-09-03 11:17 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-31  8:37 Moving my init.el to Org Marcin Borkowski
2014-08-31  9:20 ` Thorsten Jolitz
2014-08-31 10:05   ` Thorsten Jolitz
2014-08-31 12:45   ` Alan Schmitt
2014-08-31 14:12     ` Thorsten Jolitz
2014-09-01 20:27       ` Alan Schmitt
2014-09-01 21:24         ` Thorsten Jolitz
2014-09-02  8:20           ` Alan Schmitt
2014-09-02  9:22             ` Thorsten Jolitz
2014-08-31 10:37 ` Rasmus
2014-08-31 12:41 ` Grant Rettke
2014-09-01  1:24 ` Brady Trainor
2014-09-01 15:27 ` Oleh
2014-09-02  9:01   ` Rainer M Krug
2014-09-02 12:42     ` Rasmus
2014-09-02 12:52       ` Jonathan Leech-Pepin
2014-09-03  6:49         ` Rainer M Krug
2014-09-03 11:17     ` Oleh [this message]
2014-09-03 11:48       ` Rainer M Krug
2014-09-05 14:27 ` Marcin Borkowski
2014-09-06  2:49   ` Thorsten Jolitz
2014-09-06  9:26     ` Eduardo Ochs
2014-09-06 10:10       ` Thorsten Jolitz
2014-10-30 10:19     ` OrgStruct: start with collapsed view (was: Moving my init.el to Org) Karl Voit
2014-10-30 10:32       ` OrgStruct: start with collapsed view Rasmus
2014-10-30 12:41       ` Thorsten Jolitz
2014-10-31 22:10         ` Scott Randby
2014-11-01 10:16           ` Karl Voit
2014-11-01 10:44           ` Thorsten Jolitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAA01p3qx=s0Obxc7cchKcLGj0osKgkBadN66AUPk_NNmi8w8TA@mail.gmail.com' \
    --to=ohwoeowho@gmail.com \
    --cc=Rainer@krugs.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).