User:ErsatzCulture/DevelopmentNotes

From ISFDB
< User:ErsatzCulture
Revision as of 06:35, 4 October 2019 by ErsatzCulture (talk | contribs) (Have this as its own page rather than a section on my main page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Development notes

emacs setup

My emacs setup is a long messy hackup assembled over decades, so it's not going to get shared publicly. However, for the benefit of anyone else, here's an ISFDB-specific snippet I have to follow Development#Code_Format (I use 4-space indentation for all of my personal and work projects):

   (add-hook 'python-mode-hook
         (lambda()
           (if (buffer-file-name)
               (when (or (string-prefix-p "/var/www/cgi-bin/" (buffer-file-name))
                         (string-prefix-p "/proj/3rdparty/isfdb-code-svn/" (buffer-file-name)))
                 ;; http://www.isfdb.org/wiki/index.php/Development#Coding_style
                 (setq tab-width 8)
                 (setq python-indent 8)
                 (setq default-tab-width 8)
                 (setq python-index-offset 8)
                 (setq python-indent-guess-indent-offset 8)
                 (message "Using ISFDB indentation standards")
                 )
             )
           )
         )

Obviously you'd need to switch the directory paths to wherever you've checked out the code. Setting all of those variables is almost certainly overkill, but after spending too long fighting elisp to do what I want, I haven't been inclined to reduce it down to just what is needed.

Caveats:

  1. Assumes you're using python-mode
  2. Doesn't (currently) honour the Coding style rule about honouring tabs on files that are currently tab-only, but there are actually relatively few of those - see Talk:Development#Code_style:_tabs_vs_spaces

I also have these lines:

   ;; and .cgi suffix (for ISFDB)
   (add-to-list 'auto-mode-alist '("\\.cgi$" . python-mode))

Not sure how much they are needed, as (a) you probably shouldn't be editing the CGI versions, and (b) the shebang line might be enough to clue emacs that these are Python files without needing to match the suffix.