Skip to content

Commit e26d3d4

Browse files
committed
FIX: include user context values in the help output
resolves: Oldes/Rebol-issues#1155
1 parent cfe7e2a commit e26d3d4

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

src/mezz/mezz-help.reb

+26-10
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ import module [
124124
/weak "Provides sorting and does not displays unset values"
125125
/match "Include only those that match a string or datatype"
126126
pattern
127-
/only {Do not display "no info" message}
128-
/local start wild type str result
127+
/local start wild type str result user?
129128
][
130129
result: clear ""
130+
user?: same? obj system/contexts/user
131131
; Search for matching strings:
132132
wild: all [string? pattern find pattern "*"]
133133
foreach [word val] obj [
@@ -150,6 +150,9 @@ import module [
150150
type = :pattern
151151
]
152152
][
153+
; don't show user context values if these are same like library ones
154+
if all [user? any [ word = 'lib-local same? val select system/contexts/lib word]][ continue ]
155+
153156
str: join "^[[1;32m" form-pad word 15
154157
append str "^[[m "
155158
append str form-pad type 11 - min 0 ((length? str) - 15)
@@ -161,9 +164,7 @@ import module [
161164
]
162165
]
163166
]
164-
either all [pattern empty? result not only] [
165-
ajoin ["No information on: ^[[32m" pattern "^[[m^/"]
166-
][ copy result ]
167+
copy result
167168
]
168169

169170
out-description: func [des [block!]][
@@ -179,12 +180,11 @@ import module [
179180
'word [any-type!]
180181
/into "Help text will be inserted into provided string instead of printed"
181182
string [string!] "Returned series will be past the insertion"
182-
/local value spec args refs rets type ret desc arg def des ref str cols
183+
/local value spec args refs rets type ret desc arg def des ref str cols tmp
183184
][
184185
;@@ quering buffer width in CI under Windows now throws error: `Access error: protocol error: 6`
185186
;@@ it should return `none` like under Posix systems!
186-
cols: try [ query/mode system/ports/input 'buffer-cols ]
187-
unless integer? cols [ cols: 120 ]
187+
cols: any [ attempt [ query/mode system/ports/input 'buffer-cols ] 120]
188188
max-desc-width: cols - 35
189189
buffer: any [string clear ""]
190190
catch [
@@ -209,7 +209,20 @@ import module [
209209
][ word: mold :word ] ;or use it as a string input
210210
]
211211
string? :word [
212-
output dump-obj/weak/match system/contexts/lib :word
212+
tmp: false
213+
case/all [
214+
not empty? value: dump-obj/weak/match system/contexts/lib :word [
215+
output ajoin ["Found these related matches:^/" value]
216+
tmp: true
217+
]
218+
not empty? value: dump-obj/weak/match system/contexts/user :word [
219+
output ajoin ["Found these related matches in the user context:^/" value]
220+
tmp: true
221+
]
222+
not tmp [
223+
output ajoin ["No information on: ^[[32m" :word "^[[m^/"]
224+
]
225+
]
213226
throw true
214227
]
215228
datatype? :value [
@@ -226,9 +239,12 @@ import module [
226239
"It is defined as" either find "aeiou" first spec/title [" an "] [" a "] spec/title ".^/"
227240
"It is of the general type ^[[1;32m" spec/type "^[[m.^/^/"
228241
]
229-
unless empty? value: dump-obj/match/only system/contexts/lib :word [
242+
unless empty? value: dump-obj/match system/contexts/lib :word [
230243
output ajoin ["Found these related words:^/" value]
231244
]
245+
unless empty? value: dump-obj/match system/contexts/user :word [
246+
output ajoin ["Found these related words in the user context:^/" value]
247+
]
232248
]
233249
throw true
234250
]

0 commit comments

Comments
 (0)