* [9fans] Sam commands in acme @ 2009-06-26 9:50 hugo rivera 2009-06-26 10:42 ` yy 2009-06-26 10:57 ` roger peppe 0 siblings, 2 replies; 11+ messages in thread From: hugo rivera @ 2009-06-26 9:50 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs Hi, I am trying to select all c comments from within a file using acme, but I am unable to do it properly. The command x/\/\*.*\*\// is the closest I could get, but it doesn't work with comments that span over more than one line. This raises a question for me: somewhere, I cannot recall where, I read that commands in sam (and therefore acme) aren't line oriented but selection oriented, so, shouldn't '.*' match newline characters also? why it doesn't? I expected '.*' to work with newline characters since it works for spaces and tabs, and the three of them are white space, among others. And finally, what command I should use to select c comments without regard if they are several lines long or just one? Saludos -- Hugo ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Sam commands in acme 2009-06-26 9:50 [9fans] Sam commands in acme hugo rivera @ 2009-06-26 10:42 ` yy 2009-06-26 11:54 ` hugo rivera 2009-06-26 10:57 ` roger peppe 1 sibling, 1 reply; 11+ messages in thread From: yy @ 2009-06-26 10:42 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs 2009/6/26 hugo rivera <uair00@gmail.com>: > Hi, > I am trying to select all c comments from within a file using acme, > but I am unable to do it properly. The command x/\/\*.*\*\// is the > closest I could get, but it doesn't work with comments that span over > more than one line. This raises a question for me: somewhere, I cannot > recall where, I read that commands in sam (and therefore acme) aren't > line oriented but selection oriented, so, shouldn't '.*' match newline > characters also? why it doesn't? I expected '.*' to work with newline > characters since it works for spaces and tabs, and the three of them > are white space, among others. You could use (\n|.) to match any character including newlines (regex(6) says that a new line is not cosidered "any character", and as a matter of fact, \n is part of the sam language, not of regex itself). However, since the longest possible regex will be matched, then you will also match the end of the comment, so for example in: /* comment 1 */ bar /* comment 2 */ you will match everything, I don't think that is what you want. > And finally, what command I should use to select c comments without > regard if they are several lines long or just one? Edit ,x/\/\*/.,/\*\//c/COMMENT/ The possibility of modifying the dot is powerful. Many times it is much easier than finding an huge regex. > Saludos > -- > Hugo > > Un saludo, -- - yiyus || JGL . ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Sam commands in acme 2009-06-26 10:42 ` yy @ 2009-06-26 11:54 ` hugo rivera 2009-06-26 12:05 ` Rudolf Sykora 0 siblings, 1 reply; 11+ messages in thread From: hugo rivera @ 2009-06-26 11:54 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs I tested the command you suggested (,x/\/\*/.,/\*\//) and it works as I wanted, thanks. But there's something I still don't understand and is the meaning of that comma in there. As far as I know, the comma is a mark that delimits the addresses that acme understands, but I do not know how a comma is interpreted inside a regexp. I'd really appreciate if you could clarify this matter to me. 2009/6/26 yy <yiyu.jgl@gmail.com>: > 2009/6/26 hugo rivera <uair00@gmail.com>: >> Hi, >> I am trying to select all c comments from within a file using acme, >> but I am unable to do it properly. The command x/\/\*.*\*\// is the >> closest I could get, but it doesn't work with comments that span over >> more than one line. This raises a question for me: somewhere, I cannot >> recall where, I read that commands in sam (and therefore acme) aren't >> line oriented but selection oriented, so, shouldn't '.*' match newline >> characters also? why it doesn't? I expected '.*' to work with newline >> characters since it works for spaces and tabs, and the three of them >> are white space, among others. > > You could use (\n|.) to match any character including newlines > (regex(6) says that a new line is not cosidered "any character", and > as a matter of fact, \n is part of the sam language, not of regex > itself). However, since the longest possible regex will be matched, > then you will also match the end of the comment, so for example in: > /* comment 1 */ > bar > /* comment 2 */ > you will match everything, I don't think that is what you want. > >> And finally, what command I should use to select c comments without >> regard if they are several lines long or just one? > > Edit ,x/\/\*/.,/\*\//c/COMMENT/ > > The possibility of modifying the dot is powerful. Many times it is > much easier than finding an huge regex. > >> Saludos >> -- >> Hugo >> >> > > Un saludo, > > > -- > - yiyus || JGL . > > -- Hugo ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Sam commands in acme 2009-06-26 11:54 ` hugo rivera @ 2009-06-26 12:05 ` Rudolf Sykora 2009-06-26 12:21 ` hugo rivera 0 siblings, 1 reply; 11+ messages in thread From: Rudolf Sykora @ 2009-06-26 12:05 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs 2009/6/26 hugo rivera <uair00@gmail.com>: > I tested the command you suggested (,x/\/\*/.,/\*\//) and it works as > I wanted, thanks. But there's something I still don't understand and > is the meaning of that comma in there. As far as I know, the comma is > a mark that delimits the addresses that acme understands, but I do > not know how a comma is interpreted inside a regexp. I'd really > appreciate if you could clarify this matter to me. I think, the comma is not in a regexp. The 'x' command syntax is x/regexp/command and the comma is a part of the command: choose the area from the dot (included) to the '*/' Ruda ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Sam commands in acme 2009-06-26 12:05 ` Rudolf Sykora @ 2009-06-26 12:21 ` hugo rivera 0 siblings, 0 replies; 11+ messages in thread From: hugo rivera @ 2009-06-26 12:21 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs Yes, you are right. Now I understand it, I missed the / after \*, so I was thinking that the comma was inside the regexp. Thanks a lot :-) 2009/6/26 Rudolf Sykora <rudolf.sykora@gmail.com>: > 2009/6/26 hugo rivera <uair00@gmail.com>: >> I tested the command you suggested (,x/\/\*/.,/\*\//) and it works as >> I wanted, thanks. But there's something I still don't understand and >> is the meaning of that comma in there. As far as I know, the comma is >> a mark that delimits the addresses that acme understands, but I do >> not know how a comma is interpreted inside a regexp. I'd really >> appreciate if you could clarify this matter to me. > > I think, the comma is not in a regexp. The 'x' command syntax is > x/regexp/command > and the comma is a part of the command: choose the area from the dot > (included) to the '*/' > > Ruda > > -- Hugo ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Sam commands in acme 2009-06-26 9:50 [9fans] Sam commands in acme hugo rivera 2009-06-26 10:42 ` yy @ 2009-06-26 10:57 ` roger peppe 2009-06-27 18:17 ` J.R. Mauro 1 sibling, 1 reply; 11+ messages in thread From: roger peppe @ 2009-06-26 10:57 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs you need (.|\n) instead of . sam originally used @ as a "match everything" character but it was removed, presumably because it was rarely used. to match C comments, you need something like this: x/\/\*([^*]|\*[^\/]|[^*\/]|\n)*\*\// 2009/6/26 hugo rivera <uair00@gmail.com>: > Hi, > I am trying to select all c comments from within a file using acme, > but I am unable to do it properly. The command x/\/\*.*\*\// is the > closest I could get, but it doesn't work with comments that span over > more than one line. This raises a question for me: somewhere, I cannot > recall where, I read that commands in sam (and therefore acme) aren't > line oriented but selection oriented, so, shouldn't '.*' match newline > characters also? why it doesn't? I expected '.*' to work with newline > characters since it works for spaces and tabs, and the three of them > are white space, among others. > And finally, what command I should use to select c comments without > regard if they are several lines long or just one? > Saludos > -- > Hugo > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Sam commands in acme 2009-06-26 10:57 ` roger peppe @ 2009-06-27 18:17 ` J.R. Mauro 2009-06-27 19:20 ` Rob Pike 0 siblings, 1 reply; 11+ messages in thread From: J.R. Mauro @ 2009-06-27 18:17 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs On Fri, Jun 26, 2009 at 6:57 AM, roger peppe<rogpeppe@gmail.com> wrote: > you need (.|\n) instead of . > > sam originally used @ as a "match everything" character > but it was removed, presumably because it was rarely used. That's a stupid reason to remove a good feature. By that token, maybe we should remove structural regular expressions since they're "rarely used" and just go back to using ed. Do you know if anyone preserved this feature and could send me the patch? > > to match C comments, you need something like this: > > x/\/\*([^*]|\*[^\/]|[^*\/]|\n)*\*\// > > 2009/6/26 hugo rivera <uair00@gmail.com>: >> Hi, >> I am trying to select all c comments from within a file using acme, >> but I am unable to do it properly. The command x/\/\*.*\*\// is the >> closest I could get, but it doesn't work with comments that span over >> more than one line. This raises a question for me: somewhere, I cannot >> recall where, I read that commands in sam (and therefore acme) aren't >> line oriented but selection oriented, so, shouldn't '.*' match newline >> characters also? why it doesn't? I expected '.*' to work with newline >> characters since it works for spaces and tabs, and the three of them >> are white space, among others. >> And finally, what command I should use to select c comments without >> regard if they are several lines long or just one? >> Saludos >> -- >> Hugo >> >> > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Sam commands in acme 2009-06-27 18:17 ` J.R. Mauro @ 2009-06-27 19:20 ` Rob Pike 2009-06-27 20:32 ` J.R. Mauro 2009-06-29 17:03 ` roger peppe 0 siblings, 2 replies; 11+ messages in thread From: Rob Pike @ 2009-06-27 19:20 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs On Sat, Jun 27, 2009 at 11:17 AM, J.R. Mauro<jrm8005@gmail.com> wrote: > On Fri, Jun 26, 2009 at 6:57 AM, roger peppe<rogpeppe@gmail.com> wrote: >> you need (.|\n) instead of . >> >> sam originally used @ as a "match everything" character >> but it was removed, presumably because it was rarely used. > > That's a stupid reason to remove a good feature. By that token, maybe > we should remove structural regular expressions since they're "rarely > used" and just go back to using ed. Indeed, but it's an excellent reason to remove a bad feature. @ was a bad feature. It was hard to use well because @* or @+ would consume the whole file. Plus it was barely a feature, just a convenience entirely equivalent to (.|\n), which, by the way, you almost never see. It went in when we didn't yet know how the all-one-string model of sam would turn out. It turned out just fine and didn't need the @ feature, so out it went. After several years went by without my using it once, while @ simultaneously became useful as a real character so annoying as a metacharacter, out it went. Deletion is the greatest tool of software design. -rob ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Sam commands in acme 2009-06-27 19:20 ` Rob Pike @ 2009-06-27 20:32 ` J.R. Mauro 2009-06-29 17:03 ` roger peppe 1 sibling, 0 replies; 11+ messages in thread From: J.R. Mauro @ 2009-06-27 20:32 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs On Sat, Jun 27, 2009 at 3:20 PM, Rob Pike<robpike@gmail.com> wrote: > > Indeed, but it's an excellent reason to remove a bad feature. @ was a > bad feature. It was hard to use well because @* or @+ would consume > the whole file. Your structural regex paper gripes about . and * not consuming newlines. Apparently it didn't work in practice as you say, but have you thought about a different way that might work since? Changing the delimiter based on context would seem like a good, though heavyweight and probably harder-to-understand approach. > > Deletion is the greatest tool of software design. > Quite, though this one in particular seems much less out of place in sam compared to * despite its glaring faults. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Sam commands in acme 2009-06-27 19:20 ` Rob Pike 2009-06-27 20:32 ` J.R. Mauro @ 2009-06-29 17:03 ` roger peppe 2009-06-29 17:20 ` erik quanstrom 1 sibling, 1 reply; 11+ messages in thread From: roger peppe @ 2009-06-29 17:03 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs 2009/6/27 Rob Pike <robpike@gmail.com>: > Deletion is the greatest tool of software design. yes, i always get great pleasure from deleting code. unfortunately the overall line count almost always seems to trend upwards regardless of the amount of code deleted. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Sam commands in acme 2009-06-29 17:03 ` roger peppe @ 2009-06-29 17:20 ` erik quanstrom 0 siblings, 0 replies; 11+ messages in thread From: erik quanstrom @ 2009-06-29 17:20 UTC (permalink / raw) To: 9fans > unfortunately the overall line count almost always seems to trend > upwards regardless of the amount of code deleted. we are unwitting wack-a-mole players. - erik ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2009-06-29 17:20 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-06-26 9:50 [9fans] Sam commands in acme hugo rivera 2009-06-26 10:42 ` yy 2009-06-26 11:54 ` hugo rivera 2009-06-26 12:05 ` Rudolf Sykora 2009-06-26 12:21 ` hugo rivera 2009-06-26 10:57 ` roger peppe 2009-06-27 18:17 ` J.R. Mauro 2009-06-27 19:20 ` Rob Pike 2009-06-27 20:32 ` J.R. Mauro 2009-06-29 17:03 ` roger peppe 2009-06-29 17:20 ` erik quanstrom
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).