summaryrefslogtreecommitdiffhomepage
path: root/elisp.html.markdown
diff options
context:
space:
mode:
authorJostein Kjønigsen <jostein@kjonigsen.net>2014-04-29 22:10:55 +0200
committerJostein Kjønigsen <jostein@kjonigsen.net>2014-04-29 22:10:55 +0200
commit913ab2bc2ed570eb4890feb979db9aa2ce21e7ca (patch)
tree0ab8b18c05f6f6262065e63ef5482827271fdeff /elisp.html.markdown
parent5dd3cb92747a0c68a6072e19ca798adb2caf0fe9 (diff)
Syntax errors. Regexp needs to be greedier.
Diffstat (limited to 'elisp.html.markdown')
-rw-r--r--elisp.html.markdown14
1 files changed, 7 insertions, 7 deletions
diff --git a/elisp.html.markdown b/elisp.html.markdown
index d3910759..3208ffb8 100644
--- a/elisp.html.markdown
+++ b/elisp.html.markdown
@@ -280,10 +280,10 @@ filename: learn-emacs-lisp.el
;; should stop searching at some point in the buffer, and whether it
;; should silently fail when nothing is found:
-;; (search-forward "Hello" nil t) does the trick:
+;; (search-forward "Hello" nil 't) does the trick:
;; The `nil' argument says: the search is not bound to a position.
-;; The `t' argument says: silently fail when nothing is found.
+;; The `'t' argument says: silently fail when nothing is found.
;; We use this sexp in the function below, which doesn't throw an error:
@@ -294,7 +294,7 @@ filename: learn-emacs-lisp.el
(mapcar 'hello list-of-names)
(goto-char (point-min))
;; Replace "Hello" by "Bonjour"
- (while (search-forward "Hello" nil t)
+ (while (search-forward "Hello" nil 't)
(replace-match "Bonjour"))
(other-window 1))
@@ -305,7 +305,7 @@ filename: learn-emacs-lisp.el
(defun boldify-names ()
(switch-to-buffer-other-window "*test*")
(goto-char (point-min))
- (while (re-search-forward "Bonjour \\(.+\\)!" nil t)
+ (while (re-search-forward "Bonjour \\([^!]+\\)!" nil 't)
(add-text-properties (match-beginning 1)
(match-end 1)
(list 'face 'bold)))
@@ -317,9 +317,9 @@ filename: learn-emacs-lisp.el
;; The regular expression is "Bonjour \\(.+\\)!" and it reads:
;; the string "Bonjour ", and
-;; a group of | this is the \\( ... \\) construct
-;; any character | this is the .
-;; possibly repeated | this is the +
+;; a group of | this is the \\( ... \\) construct
+;; any character not ! | this is the [^!]
+;; possibly repeated | this is the +
;; and the "!" string.
;; Ready? Test it!