From 9f1560ba5203362363954543f96816695bf5f160 Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Wed, 18 Feb 2015 00:41:35 +0100 Subject: [PATCH 1/3] Use string-prefix-p instead of haskell-is-prefix-of. --- haskell-session.el | 4 ++-- haskell-string.el | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/haskell-session.el b/haskell-session.el index b87a33228..65ac11e03 100644 --- a/haskell-session.el +++ b/haskell-session.el @@ -64,8 +64,8 @@ (cl-reduce (lambda (acc a) (let ((dir (haskell-session-cabal-dir a t))) (if dir - (if (haskell-is-prefix-of dir - (file-name-directory (buffer-file-name))) + (if (string-prefix-p dir + (file-name-directory (buffer-file-name))) (if acc (if (and (> (length (haskell-session-cabal-dir a t)) diff --git a/haskell-string.el b/haskell-string.el index 9c4255df4..b471ef7d7 100644 --- a/haskell-string.el +++ b/haskell-string.el @@ -13,11 +13,6 @@ 0 (min (length string) n))) -;;;###autoload -(defun haskell-is-prefix-of (x y) - "Is x string a prefix of y string?" - (string= x (substring y 0 (min (length y) (length x))))) - (defun haskell-string ()) (provide 'haskell-string) From 19a9900d287c8d53dec77d89bcc6d9939925b68e Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Wed, 18 Feb 2015 00:42:35 +0100 Subject: [PATCH 2/3] Remove unecessary haskell-str-is-prefix-of-p. --- haskell-str.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/haskell-str.el b/haskell-str.el index 872d46d8d..5e998733a 100644 --- a/haskell-str.el +++ b/haskell-str.el @@ -51,8 +51,6 @@ Note: The implementation currently only supports ASCII "Return (up to) N character length prefix of STRING." (substring string 0 (min (length string) n))) -(defalias 'haskell-str-is-prefix-of-p 'string-prefix-p) - (defun haskell-str-is-suffix-of-p (str1 str2 &optional ignore-case) "Return non-nil if STR1 is a suffix of STR2. If IGNORE-CASE is non-nil, the comparison is done without paying attention From 04f5e141b1ccc7cc2f5aca74b45f0221db3f32ef Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Wed, 18 Feb 2015 00:44:24 +0100 Subject: [PATCH 3/3] Use standard string-suffix-p. Use standard string-suffix-p in place of haskell-str-is-suffix-of-p. --- haskell-str.el | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/haskell-str.el b/haskell-str.el index 5e998733a..9fe2df491 100644 --- a/haskell-str.el +++ b/haskell-str.el @@ -51,17 +51,6 @@ Note: The implementation currently only supports ASCII "Return (up to) N character length prefix of STRING." (substring string 0 (min (length string) n))) -(defun haskell-str-is-suffix-of-p (str1 str2 &optional ignore-case) - "Return non-nil if STR1 is a suffix of STR2. -If IGNORE-CASE is non-nil, the comparison is done without paying attention -to case differences. - -Dual to `haskell-str-is-prefix-of-p'" - (let ((pos (- (length str2) (length str1)))) - (if (>= pos 0) - (eq t (compare-strings str1 nil nil - str2 pos nil ignore-case))))) - (defconst haskell-str-literal-encode-ascii-array [ "\\NUL" "\\SOH" "\\STX" "\\ETX" "\\EOT" "\\ENQ" "\\ACK" "\\a" "\\b" "\\t" "\\n" "\\v" "\\f" "\\r" "\\SO" "\\SI" "\\DLE" "\\DC1" "\\DC2" "\\DC3" "\\DC4" "\\NAK" "\\SYN" "\\ETB" "\\CAN" "\\EM" "\\SUB" "\\ESC" "\\FS" "\\GS" "\\RS" "\\US" " " "!" "\\\"" "#" "$" "%" "&" "'" "(" ")" "*" "+" "," "-" "." "/" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" ":" ";" "<" "=" ">" "?" "@" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" "[" "\\\\" "]" "^" "_" "`" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "{" "|" "}" "~" "\\DEL" ] "Array of encodings for 7-bit ASCII character points indexed by ASCII value.")