Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emacs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
emacs
emacs
Commits
ee4b1330
Commit
ee4b1330
authored
Jun 18, 2012
by
Stefan Monnier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* lisp/emacs-lisp/pcase.el (pcase--expand): Warn for unused pattern.
(pcase--u1, pcase--q1): Don't use apply-partially.
parent
35647f79
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
11 deletions
+26
-11
lisp/ChangeLog
lisp/ChangeLog
+5
-0
lisp/emacs-lisp/pcase.el
lisp/emacs-lisp/pcase.el
+21
-11
No files found.
lisp/ChangeLog
View file @
ee4b1330
2012-06-18 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/pcase.el (pcase--expand): Warn for unused pattern.
(pcase--u1, pcase--q1): Don't use apply-partially.
2012-06-18 Glenn Morris <rgm@gnu.org>
* progmodes/python.el (python-proc, python-buffer)
...
...
lisp/emacs-lisp/pcase.el
View file @
ee4b1330
...
...
@@ -237,7 +237,8 @@ of the form (UPAT EXP)."
;; the branch to a separate function.
(
let
((
bsym
(
make-symbol
(
format
"pcase-%d"
(
length
defs
)))))
(
push
`
(
,
bsym
(
lambda
,
(
mapcar
#'
car
prevvars
)
,@
code
))
defs
)
(
push
`
(
,
bsym
(
lambda
,
(
mapcar
#'
car
prevvars
)
,@
code
))
defs
)
(
setcar
res
'funcall
)
(
setcdr
res
(
cons
bsym
(
mapcar
#'
cdr
prevvars
)))
(
setcar
(
cddr
prev
)
bsym
)
...
...
@@ -255,17 +256,26 @@ of the form (UPAT EXP)."
;; FIXME: But if some of `prevvars' are not in `vars' we
;; should remove them from `prevvars'!
`
(
funcall
,
res
,@
args
)))))))
(
used-cases
())
(
main
(
pcase--u
(
mapcar
(
lambda
(
case
)
`
((
match
,
val
.
,
(
car
case
))
,
(
apply-partially
(
if
(
pcase--small-branch-p
(
cdr
case
))
;; Don't bother sharing multiple
;; occurrences of this leaf since it's small.
#'
pcase-codegen
codegen
)
(
cdr
case
))))
,
(
lambda
(
vars
)
(
unless
(
memq
case
used-cases
)
;; Keep track of the cases that are used.
(
push
case
used-cases
))
(
funcall
(
if
(
pcase--small-branch-p
(
cdr
case
))
;; Don't bother sharing multiple
;; occurrences of this leaf since it's small.
#'
pcase-codegen
codegen
)
(
cdr
case
)
vars
))))
cases
))))
(
dolist
(
case
cases
)
(
unless
(
or
(
memq
case
used-cases
)
(
eq
(
car
case
)
'dontcare
))
(
message
"Redundant pcase pattern: %S"
(
car
case
))))
(
macroexp-let*
defs
main
))))
(
defun
pcase-codegen
(
code
vars
)
...
...
@@ -566,7 +576,7 @@ Otherwise, it defers to REST which is a list of branches of the form
(
if
(
eq
(
car
upat
)
'pred
)
(
put
sym
'pcase-used
t
))
(
let*
((
splitrest
(
pcase--split-rest
sym
(
apply-partially
#'
pcase--split-pred
upat
)
rest
))
sym
(
lambda
(
pat
)
(
pcase--split-pred
upat
pat
)
)
rest
))
(
then-rest
(
car
splitrest
))
(
else-rest
(
cdr
splitrest
)))
(
pcase--if
(
if
(
and
(
eq
(
car
upat
)
'pred
)
(
symbolp
(
cadr
upat
)))
...
...
@@ -636,7 +646,7 @@ Otherwise, it defers to REST which is a list of branches of the form
(
let*
((
elems
(
mapcar
'cadr
(
cdr
upat
)))
(
splitrest
(
pcase--split-rest
sym
(
apply-partially
#'
pcase--split-member
elems
)
rest
))
sym
(
lambda
(
pat
)
(
pcase--split-member
elems
pat
)
)
rest
))
(
then-rest
(
car
splitrest
))
(
else-rest
(
cdr
splitrest
)))
(
put
sym
'pcase-used
t
)
...
...
@@ -693,7 +703,7 @@ Otherwise, it defers to REST which is a list of branches of the form
(
symd
(
make-symbol
"xcdr"
))
(
splitrest
(
pcase--split-rest
sym
(
apply-partially
#'
pcase--split-consp
syma
symd
)
(
lambda
(
pat
)
(
pcase--split-consp
syma
symd
pat
)
)
rest
))
(
then-rest
(
car
splitrest
))
(
else-rest
(
cdr
splitrest
))
...
...
@@ -716,7 +726,7 @@ Otherwise, it defers to REST which is a list of branches of the form
(
pcase--u
else-rest
))))
((
or
(
integerp
qpat
)
(
symbolp
qpat
)
(
stringp
qpat
))
(
let*
((
splitrest
(
pcase--split-rest
sym
(
apply-partially
'pcase--split-equal
qpat
)
rest
))
sym
(
lambda
(
pat
)
(
pcase--split-equal
qpat
pat
)
)
rest
))
(
then-rest
(
car
splitrest
))
(
else-rest
(
cdr
splitrest
)))
(
pcase--if
(
cond
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment