From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleh Subject: Re: Moving my init.el to Org Date: Wed, 3 Sep 2014 13:17:00 +0200 Message-ID: References: <20140831103706.549dc45b@aga-netbook> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XP8Yg-00028I-Mm for emacs-orgmode@gnu.org; Wed, 03 Sep 2014 07:17:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XP8Yf-00047t-D2 for emacs-orgmode@gnu.org; Wed, 03 Sep 2014 07:17:02 -0400 Received: from mail-vc0-x230.google.com ([2607:f8b0:400c:c03::230]:35119) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XP8Yf-00047U-8T for emacs-orgmode@gnu.org; Wed, 03 Sep 2014 07:17:01 -0400 Received: by mail-vc0-f176.google.com with SMTP id ik5so8598851vcb.35 for ; Wed, 03 Sep 2014 04:17:00 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Rainer M Krug Cc: Org-mode mailing list >> 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 "") 'js-f5) (define-key js-mode-map (kbd "C-") '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