Skip to content
This repository
Browse code

Modelines may be now customized per-mode.

  • Loading branch information...
commit ab2aefdf4ba9c37c8d3ab4511398e744a445c101 1 parent 0351291
mgajda authored September 18, 2011 coreyoconnor committed March 19, 2012

Showing 1 changed file with 10 additions and 3 deletions. Show diff stats Hide diff stats

  1. 13  yi/src/library/Yi/Buffer/Misc.hs
13  yi/src/library/Yi/Buffer/Misc.hs
@@ -398,7 +398,8 @@ data Mode syntax = Mode
398 398
      modeGetAnnotations :: syntax -> Point -> [Span String],
399 399
      modePrintTree :: syntax -> BufferM (),
400 400
      -- should this be an Action instead?
401  
-     modeOnLoad :: BufferM () -- ^ An action that is to be executed when this mode is set
  401
+     modeOnLoad :: BufferM (), -- ^ An action that is to be executed when this mode is set
  402
+     modeModeLine :: [String] -> BufferM String -- ^ buffer-local modeline formatting method
402 403
     }
403 404
 
404 405
 instance Binary (Mode syntax) where
@@ -442,8 +443,13 @@ instance Show FBuffer where
442 443
 -- N.B. the contents of modelines should be specified by user, and
443 444
 -- not hardcoded.
444 445
 --
  446
+
445 447
 getModeLine :: [String] -> BufferM String
446  
-getModeLine prefix = do
  448
+getModeLine prefix = withModeB (\m -> (modeModeLine m) prefix)
  449
+
  450
+defaultModeLine :: [String] -> BufferM String
  451
+defaultModeLine prefix = do
  452
+    col <- curCol
447 453
     col <- curCol
448 454
     pos <- pointB
449 455
     ln <- curLn
@@ -607,7 +613,8 @@ emptyMode = Mode
607 613
    modeGetStrokes = \_ _ _ _ -> [],
608 614
    modeGetAnnotations = \_ _ -> [],
609 615
    modePrintTree = \_ -> return (),
610  
-   modeOnLoad = return ()
  616
+   modeOnLoad = return (),
  617
+   modeModeLine = defaultModeLine
611 618
   }
612 619
 
613 620
 -- | Create buffer named @nm@ with contents @s@

0 notes on commit ab2aefd

Please sign in to comment.
Something went wrong with that request. Please try again.