mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-27 09:15:50 +03:00
Syntax errors. Regexp needs to be greedier.
This commit is contained in:
parent
5dd3cb9274
commit
913ab2bc2e
@ -280,10 +280,10 @@ filename: learn-emacs-lisp.el
|
|||||||
;; should stop searching at some point in the buffer, and whether it
|
;; should stop searching at some point in the buffer, and whether it
|
||||||
;; should silently fail when nothing is found:
|
;; 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 `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:
|
;; 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)
|
(mapcar 'hello list-of-names)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
;; Replace "Hello" by "Bonjour"
|
;; Replace "Hello" by "Bonjour"
|
||||||
(while (search-forward "Hello" nil t)
|
(while (search-forward "Hello" nil 't)
|
||||||
(replace-match "Bonjour"))
|
(replace-match "Bonjour"))
|
||||||
(other-window 1))
|
(other-window 1))
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ filename: learn-emacs-lisp.el
|
|||||||
(defun boldify-names ()
|
(defun boldify-names ()
|
||||||
(switch-to-buffer-other-window "*test*")
|
(switch-to-buffer-other-window "*test*")
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward "Bonjour \\(.+\\)!" nil t)
|
(while (re-search-forward "Bonjour \\([^!]+\\)!" nil 't)
|
||||||
(add-text-properties (match-beginning 1)
|
(add-text-properties (match-beginning 1)
|
||||||
(match-end 1)
|
(match-end 1)
|
||||||
(list 'face 'bold)))
|
(list 'face 'bold)))
|
||||||
@ -317,9 +317,9 @@ filename: learn-emacs-lisp.el
|
|||||||
|
|
||||||
;; The regular expression is "Bonjour \\(.+\\)!" and it reads:
|
;; The regular expression is "Bonjour \\(.+\\)!" and it reads:
|
||||||
;; the string "Bonjour ", and
|
;; the string "Bonjour ", and
|
||||||
;; a group of | this is the \\( ... \\) construct
|
;; a group of | this is the \\( ... \\) construct
|
||||||
;; any character | this is the .
|
;; any character not ! | this is the [^!]
|
||||||
;; possibly repeated | this is the +
|
;; possibly repeated | this is the +
|
||||||
;; and the "!" string.
|
;; and the "!" string.
|
||||||
|
|
||||||
;; Ready? Test it!
|
;; Ready? Test it!
|
||||||
|
Loading…
Reference in New Issue
Block a user