improve handling of DrRacket file extensions

pull/175/head
Matthew Butterick 7 years ago
parent 7fed0d10e2
commit 655003c1d9

@ -5,4 +5,4 @@
(define compile-omit-paths '("test" "tools" "server-extras" "scribblings/third-tutorial-files"))
;; it's redundant to test "pollen.scrbl" because it incorporates the other scribble sources by reference
(define test-omit-paths '("test/data" "tools" "server-extras" "scribblings/third-tutorial-files" "scribblings/pollen.scrbl"))
(define module-suffixes '(#"pp" #"pm" #"pmd" #"ptree"))
(define module-suffixes '(#"p" #"pp" #"pm" #"pmd" #"ptree"))

@ -1,6 +1,14 @@
#lang racket/base
(require racket/syntax syntax/strip-context racket/class (for-syntax racket/base))
(require (only-in scribble/reader make-at-reader) "../setup.rkt" "project.rkt")
(require racket/syntax
syntax/strip-context
racket/class
racket/string
racket/runtime-path
setup/getinfo
(for-syntax racket/base)
(only-in scribble/reader make-at-reader)
"../setup.rkt"
"project.rkt")
(provide (rename-out [reader-module-begin #%module-begin]) (all-from-out "../setup.rkt"))
(define (path-string->here-path path-string)
@ -9,7 +17,6 @@
[(equal? path-string "unsaved editor") path-string]
[else (path->string path-string)]))
(define (infer-parser-mode reader-mode reader-here-path)
(if (eq? reader-mode default-mode-auto)
(let* ([file-ext-pattern (pregexp "\\w+$")]
@ -63,6 +70,8 @@
(provide (all-from-out 'POLLEN-MOD-NAME))
(show DOC 'PARSER-MODE-FROM-READER HERE-PATH))))) ; HERE-PATH otherwise acts as "local" runtime config
(define-runtime-path info-dir "..")
(define ((custom-get-info mode) in mod line col pos)
;; DrRacket caches source file information per session,
;; so we can do the same to avoid multiple searches for the command char.
@ -90,15 +99,19 @@
[(drracket:indentation)
(dynamic-require 'scribble/private/indentation 'determine-spaces)]
[(drracket:default-filters)
'(("Pollen Sources" "*.pp;*.pmd;*.pm;*.ptree;*.ptree;*.p"))]
;; derive this from `module-suffixes` entry in main info.rkt file
(define module-suffixes ((get-info/full info-dir) 'module-suffixes))
(define filter-strings (for/list ([suffix (in-list module-suffixes)])
(format "*.~a" suffix)))
(list (list "Pollen sources" (string-join filter-strings ";")))]
[(drracket:default-extension)
(case mode
[(default-mode-auto) "pp"]
[(default-mode-preproc) "pp"]
[(default-mode-markdown) "pmd"]
[(default-mode-markup) "pm"]
[(default-mode-ptree) "ptree"]
[else "pm"])]
(symbol->string
(cond
[(eq? mode default-mode-auto) (setup:preproc-source-ext)]
[(eq? mode default-mode-preproc) (setup:preproc-source-ext)]
[(eq? mode default-mode-markdown) (setup:markdown-source-ext)]
[(eq? mode default-mode-markup) (setup:markup-source-ext)]
[(eq? mode default-mode-pagetree) (setup:pagetree-source-ext)]))]
[else default]))))
(define-syntax-rule (reader-module-begin mode . _)

@ -1 +1 @@
1524148197
1524342806

Loading…
Cancel
Save