Skip to content

Commit

Permalink
Modelines may be now customized per-mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgajda authored and Corey O'Connor committed Mar 20, 2012
1 parent 0351291 commit ab2aefd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions yi/src/library/Yi/Buffer/Misc.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ data Mode syntax = Mode
modeGetAnnotations :: syntax -> Point -> [Span String], modeGetAnnotations :: syntax -> Point -> [Span String],
modePrintTree :: syntax -> BufferM (), modePrintTree :: syntax -> BufferM (),
-- should this be an Action instead? -- should this be an Action instead?
modeOnLoad :: BufferM () -- ^ An action that is to be executed when this mode is set modeOnLoad :: BufferM (), -- ^ An action that is to be executed when this mode is set
modeModeLine :: [String] -> BufferM String -- ^ buffer-local modeline formatting method
} }


instance Binary (Mode syntax) where instance Binary (Mode syntax) where
Expand Down Expand Up @@ -442,8 +443,13 @@ instance Show FBuffer where
-- N.B. the contents of modelines should be specified by user, and -- N.B. the contents of modelines should be specified by user, and
-- not hardcoded. -- not hardcoded.
-- --

getModeLine :: [String] -> BufferM String getModeLine :: [String] -> BufferM String
getModeLine prefix = do getModeLine prefix = withModeB (\m -> (modeModeLine m) prefix)

defaultModeLine :: [String] -> BufferM String
defaultModeLine prefix = do
col <- curCol
col <- curCol col <- curCol
pos <- pointB pos <- pointB
ln <- curLn ln <- curLn
Expand Down Expand Up @@ -607,7 +613,8 @@ emptyMode = Mode
modeGetStrokes = \_ _ _ _ -> [], modeGetStrokes = \_ _ _ _ -> [],
modeGetAnnotations = \_ _ -> [], modeGetAnnotations = \_ _ -> [],
modePrintTree = \_ -> return (), modePrintTree = \_ -> return (),
modeOnLoad = return () modeOnLoad = return (),
modeModeLine = defaultModeLine
} }


-- | Create buffer named @nm@ with contents @s@ -- | Create buffer named @nm@ with contents @s@
Expand Down

0 comments on commit ab2aefd

Please sign in to comment.