emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/omn-mode 0fcc57f 1/2: Improved syntax handling for URLs


From: Phillip Lord
Subject: [elpa] externals/omn-mode 0fcc57f 1/2: Improved syntax handling for URLs.
Date: Tue, 01 Sep 2015 16:38:44 +0000

branch: externals/omn-mode
commit 0fcc57f43e4c304efa15a94a35147f06b3a7560f
Author: Phillip Lord <address@hidden>
Commit: Phillip Lord <address@hidden>

    Improved syntax handling for URLs.
    
    * (omn-mode): Now sets a syntax-propertize-function to identify URLs
      more accurately. This addresses mis-identification of "<" and ">" when
      used as facets.
    * (omn-mode-syntax-table): No longer handles URLs.
---
 omn-mode.el |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/omn-mode.el b/omn-mode.el
index f978093..d9eba50 100644
--- a/omn-mode.el
+++ b/omn-mode.el
@@ -172,15 +172,6 @@ See `imenu-generic-expression' for details")
   (let ((st (make-syntax-table)))
     ;; string quotes
     (modify-syntax-entry ?\" "\"" st)
-    ;; This is a bit underhand, but we define the < and > characters to be
-    ;; "generic-string" delimiters. This results in fontification for URLs
-    ;; which is no bad thing. Additionally, it makes the comment character
-    ;; work, as "#" is a valid in a URL. The semantics of this isn't quite
-    ;; right, because the two characters are not paired. So <url> is
-    ;; recognised, but so is <url< or >url>.
-    ;; We could use a syntax-propertize-function to do more carefully.
-    (modify-syntax-entry ?\< "|" st)
-    (modify-syntax-entry ?\> "|" st)
     ;; define comment characters for syntax
     (modify-syntax-entry ?\# "<" st)
     (modify-syntax-entry ?\n ">" st)
@@ -219,6 +210,16 @@ See `imenu-generic-expression' for details")
 (define-derived-mode omn-mode fundamental-mode "Omn"
   "Doc string to add"
 
+  ;; Specialised syntax handling to recognise URLs. This is a bit underhand,
+  ;; but we define the < and > characters to be "generic-string" delimiters.
+  ;; This results in fontification for URLs which is no bad thing.
+  ;; Additionally, it makes the comment character work, as "#" is a valid in a
+  ;; URL. There is a slight irony that in a format for a web-centric document,
+  ;; we should treat URLs as having no semantics!
+  (setq-local syntax-propertize-function
+              (syntax-propertize-rules
+               ("\\(<\\)[^ ]*\\(>\\)" (1 "|") (2 "|"))))
+
   ;; font-lock stuff
   (setq font-lock-defaults
         '(omn-font-lock-defaults))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]