contrib/mercurial.el
changeset 1178 a7abffa4b19f
parent 1175 7e909ceeb36a
child 1179 8acf62f579d8
equal deleted inserted replaced
1177:862f53c1d0f9 1178:a7abffa4b19f
   281   (if (fboundp 'replace-in-string)
   281   (if (fboundp 'replace-in-string)
   282       (replace-in-string str regexp newtext literal)
   282       (replace-in-string str regexp newtext literal)
   283     (replace-regexp-in-string regexp newtext str nil literal)))
   283     (replace-regexp-in-string regexp newtext str nil literal)))
   284 
   284 
   285 (defsubst hg-strip (str)
   285 (defsubst hg-strip (str)
   286   "Strip leading and trailing white space from a string."
   286   "Strip leading and trailing blank lines from a string."
   287   (hg-replace-in-string (hg-replace-in-string str "[ \t\r\n]+$" "")
   287   (hg-replace-in-string (hg-replace-in-string str "[\r\n][ \t\r\n]*\\'" "")
   288 			"^[ \t\r\n]+" ""))
   288 			"\\`[ \t\r\n]*[\r\n]" ""))
   289 
   289 
   290 (defsubst hg-chomp (str)
   290 (defsubst hg-chomp (str)
   291   "Strip trailing newlines from a string."
   291   "Strip trailing newlines from a string."
   292   (hg-replace-in-string str "[\r\n]+$" ""))
   292   (hg-replace-in-string str "[\r\n]+\'" ""))
   293 
   293 
   294 (defun hg-run-command (command &rest args)
   294 (defun hg-run-command (command &rest args)
   295   "Run the shell command COMMAND, returning (EXIT-CODE . COMMAND-OUTPUT).
   295   "Run the shell command COMMAND, returning (EXIT-CODE . COMMAND-OUTPUT).
   296 The list ARGS contains a list of arguments to pass to the command."
   296 The list ARGS contains a list of arguments to pass to the command."
   297   (let* (exit-code
   297   (let* (exit-code