Difference between revisions of "User:ErsatzCulture"

From ISFDB
Jump to navigation Jump to search
(First (proper) content)
(emacs setup)
Line 8: Line 8:
  
 
Most of my edits to ISFDB are minor data fixes or additions in order to support these personal projects.
 
Most of my edits to ISFDB are minor data fixes or additions in order to support these personal projects.
 +
 +
= 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:
 +
 +
# Assumes you're using python-mode
 +
# 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.

Revision as of 17:28, 3 October 2019

I have a number of SF-related personal projects in various stages of completion or abandonment, many of which use a local copy of the ISFDB.

Ones that actually got to a state that I felt brave enough to expose to the rest of the world can be found here.

Some bits and pieces from works-in-progress can be found in my Twitter feed.

Some of the code I use to interrogate the database can be found on GitHub. All of this has - as of time of writing - been written without looking at the proper ISFDB code, so doubtless there are lots of stupid errors and misconceptions as to how the database is designed. The code certainly isn't going to win any awards for quality, given that much of it is the result of blundering hacking around post midnight.

Most of my edits to ISFDB are minor data fixes or additions in order to support these personal projects.

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.