logs archiveIRC Archive / Freenode / #emacs / 2009 / December / 17 / 1
neosoothsayer
hey guys, what would be the regexp to match text between 2 brace characters in Emacs replace-regexp?
chrisb
e1f: don't forget bonhomme carnival styled scarves
neosoothsayer
I need to replace the definition of a function with a ';'
so void foo() { } becomes void foo();
langmartin
neosoothsayer: braces aren't special characters unless they are escaped with backslashes
{.*} will match your example
jlf
you probably don't want a regexp for this
fledermaus
,df forward-sexp
fsbot
forward-sexp is an interactive compiled Lisp function in `lisp.el'.
It is bound to <C-M-right>, ESC <C-right>, C-M-f.
(forward-sexp &optional ARG)
Move forward across one balanced expression (sexp).
With ARG, do it that many times. Negative arg -N means ..[Type ,more]
jlf
,g friedl balanced
fsbot
[google] http://www.otterbook.com/blog/2009/07/pmotd-textbalanced/
http://www.uncwsports.com/ViewArticle.dbml%3FDB_OEM_ID%3D19800%26ATCLID%3D1257266
         

fsmunoz
neosoothsayer: I would say something like "{.*}"... but this is probably to generic
ggole
And won't handle nested parens
fsmunoz
Indeed
ggole
This is a parsing problem, not a regexp problem
neosoothsayer
langmartin: {.*} seems to match only {} chars on the same line - how about in a region?
fledermaus
i fonle there were some sort of forward-sexp function
and a keyboard macro facility
if only
neosoothsayer
yeah, I finally resorted to a kbd macro to do it
langmartin
well, this is the part where everyone else is correct that it's a parsing problem, and probably going to stay a mess with regexp.
that's what I would have done
neosoothsayer
I am learning regexps, so thought this would be a good exercise. I am bad at it right now
kbd macro did fine!
langmartin
regexp are bad for matching nested delimiters
neosoothsayer
Anyone has a book recommendation for regexps?
jlf
friedl
neosoothsayer
Mastering Regular Expressions?
jlf
yup
fledermaus
just learn the atoms and the modifiers of whichever dialect you're using.
it's not rocket surgery.
neosoothsayer
Cool
timcharper
speaking of regex... I was looking a while ago and couldn't figure out how to do a negative lookbehind in an emacs regex
jlf
neosoothsayer: be aware that elisp's regexps are different than perl's.. try reading M-: (info "(elisp)Regular Expressions") and experimenting with M-x regex-tool
fledermaus
not supported
timcharper
fledermaus: ok, I figured. Is there another way to achieve it, or do you have to brute it with elisp ?
by achieve it, I mean, another way to approach the problem
         

fledermaus
timcharper: you can't implement them with regexes if the regexp dialect doesn't support them, unfortunately
neosoothsayer
is M-x regex-tool like re-builder?
bpalmer`
timcharper: pull it into code.
timcharper
right, that is unfortunate. would be sweet.
jlf
neosoothsayer: looks like it
timcharper
neosoothsayer: you mean, M-x re-builder ?
regexp-builder
jlf
regexp-builder is an alias for re-builder
timcharper
and a fine one at that!
,,what-about-bums
fsbot
Maybe your plans have something to do with this.
neosoothsayer
Ah, I will play with that
is fuzzy matching a part of Emacs or just ido-mode?
timcharper
neosoothsayer: ido-mode
neosoothsayer
I wonder if I can do something with fuzzy matching and isearch
Ah bummer - fuzzy matching would be sweet with isearch
subversus
neosoothsayer: you sure about that?
neosoothsayer: i think you'd get a lot of hits on your search you don't want
neosoothsayer
subversus: while browsing source code, I don't think there's that much text - plus with regular trimming of the results like C-@ in ido-mode, it can be very fast
timcharper
the beautiful thing about emacs: if you want it, you can build it
neosoothsayer
yeah, thats what I did with fuzzy matching with tags in a source tree. I got tired of typing tag names
I was so happy about the being able to write some non-trivial code!
,yow
fsbot
Look! A ladder! Maybe it leads to heaven, or a sandwich!
timcharper
way to go :)
have you published it, by chance ?
jlf
neosoothsayer: i guess you know about isearch-forward-regexp..?
neosoothsayer
jlf: hmmm, no - never used it
timcharper
I've been using textmate.el for tag matching. It's really useful, behaves like TextMate's go to symbol command
err... ido-style tag matching ? whatever
neosoothsayer
jlf: I think it would be hard to use that well - because one has to think about writing regexps
jlf
nah, foo.*bar is usually enough for me
neosoothsayer
I can use it for replacing, but regular search through regexps???
fsbot
Ask yourself, do you really want to know?
ams
neosoothsayer: why not?
jlf
C-M-s or C-u C-s
timcharper
oh, searching with regexps is extremely handy
I do it frequently
jlf
(and backward with -r of course)
neosoothsayer
Ah, ok, I had not thought about using regexps for simpler cases like foo.*bar - I was thinking more in terms of the compound expressions, and the time it takes for me to come up with them
now that I know!
timcharper
and there was much rejoicing
,botsnack
fsbot
my favourite snack!
jlf
it's worth reading C-s C-h ... lots of goodies in isearch
neosoothsayer
oh - timcharper : I didnt see your 'published' remark until now
I have that code and it works well, but I am a little shy of posting it :D
I dont think my code measures up to the wiki standards
timcharper
neosoothsayer: lol. well, there's always http://paste.lisp.org/
and... wait... what's that? the wiki has standards ?
neosoothsayer
Oh - here's the link - I sent it to someone on this chat room today. http://paste.lisp.org/+1Z5K
well, people like Kensanata and DrewAdams hang out on wiki - I'm afraid of my code standing to their scrutiny
:)
timcharper
lol, I've yet to get audited by them at some point, but good to know
neosoothsayer: have you ever used exhuberant ctags ?
jlf
neosoothsayer: a few style notes/suggestions: 1) several useless uses of progn, 2) some missing docstrings, 3) (eq nil foo) === (null foo), 4) if you find yourself using if with progn, consider cond, 5) setq accepts multiple pairs of arguments, 6) use a space between function name and opening paren in defuns
neosoothsayer
I tried - but I couldnt get Emacs to accept the tags files generated by ctags...
jlf: isnt progn required to ensure that all forms are evaluated in order listed
?
jlf
neosoothsayer: there's an implicit progn in defun, cond, dolist, and elsewhere
neosoothsayer
jlf: thanks for the suggestions! I will keep them in mind for my next pieces of work!
jlf
yw
timcharper
neosoothsayer: posting code in #emacs always subjects you to free code reviews :)
anyways... re. ctags: yeah, you have to tell it to generate emacs style. I like it much better though, it supports more languages and it automatically finds supported files for you, so you don't have to run the find command
create-tags is as easy as this with ctags:
http://paste.lisp.org/+1Z5W
also... have you seen this ?
http://www.emacswiki.org/emacs/InteractivelyDoThings#toc9
the command there, 'ido-find-file-in-tag-files, lets you extract a list of files from your TAGS file
rather than having to output it to a separate file
but... maybe you already knew that...
neosoothsayer
timcharper: good tip on create-tags. I assume your path variable has the option for specifying tags file that emacs supports?
madpickle
this should all become a lot easier with the project file mode in 23.2
(in terms of adoption, i mean - it's available now and has been for a while)
timcharper
madpickle: there's a project file mode ?
madpickle
there is
timcharper
hot damn I've been looking for something like that
madpickle
part of CEDET i believe
if people start using that the whole issue of deciding when and how to generate TAGS, etc. becomes a moot point :)
neosoothsayer
Ah, I saw that - I couldnt get that code to run on my emacs. Debugging it required too much internal knowledge of find-tag function, so I just wrote my implementation
madpickle
of course, you could ghetto it now in 23 with directory-local elisp variables
(sorta, kinda...)
timcharper
when's eta for emacs 23.2 ?
is it in emacs bleeding edge ?
madpickle
it's out soonish
there's a pretest out and i hear they're planning an early January release
neosoothsayer
people here actually run CVS builds of emacs?
madpickle
could grab it now. the bleeding edge stuff is usually pretty stable.
of course.
,EDE
fsbot
madpickle, I think ede is Emacs Development Environment, an emacs project tool http://cedet.sourceforge.net/ede.shtml
neosoothsayer
not worried about crashes? I work with source code, so I am a little wary of being on anything not stable
madpickle
all experienced developers habitually save every minute
:-)
i ran emacs 23 for just under a year before it was released and never had any major issues with it.
neosoothsayer
I should get used to that - rely too much on auto save
timcharper
madpickle: how true that is. thank you for the tip, I'll give it a run.
madpickle
timcharper: i'm very excited about that addition. i mean i could trivially install EDE or a similar tool but official adoption means it's possible to develop against it.
that's why i'm hoping we can settle on *one* autocomplete framework and be done with the Not Invented Here syndrome.
timcharper
madpickle: sorry for naivety - is there a project page for emacs-project-mode ?
,,emacs-project-mode
fsbot
madpickle
fsbot: tell timcharper about EDE
fsbot
timcharper: I think ede is Emacs Development Environment, an emacs project tool http://cedet.sourceforge.net/ede.shtml
madpickle
heh. surprised that works.
timcharper
lol
madpickle
i can see now that fsbot is based on the old perl infobot
timcharper
,botsnack
fsbot
my favourite snack!
timcharper
thanks - i saw the link earlier, but didn't associate the two
madpickle
no problems
gotta love emacs, eh?
neosoothsayer
So, EDE is what its going to look like in 23.2?
madpickle
it'll have all of CEDET as well.
neosoothsayer
Ok, cool! It will take away a whole bunch of need for customizations
scottj
Anyone know a minor-mode to highlight occurences of symbol at point in the existing buffer (not occur, just change their face)?
(kind of like eclipse does)
madpickle
highlight-phrase
technomancy
,idle-highlight
fsbot
I think idle-highlight is [0] a minor mode to highlight all occurrences of the word under point.
[1] http://www.emacswiki.org/emacs/IdleHighlight
rgr
highlight-symbol.el is excellent too.
jlf
when i have the same buffer open in two windows, is it possible for each window to be narrowed to a different portion of the buffer?
fledermaus
jlf: not really, unless oyu can do something clever with indirect buffers
jlf
bummer.. i'm not too good at clever :)
rgr
hmm, idle-highlight is a cracking little addition. Nice one.
it needs a global mode though... or .. time to browse ...
timcharper
is there a proced command? like direct? aspell went nuts on me and I need to kill it
sorry... like dired
ugh... i'm retarded. ok, there is a proced command :) but it's only available on linux machines
how do I kill emacs inferior processes ?
Nafai
timcharper: I'd assume just kill the buffer associated with them
timcharper
list-processes tells me there is no buffer associated with it
(none) it says
macrobat
in my .emacs i can use (when window-system (speedbar t)) , but i get errors if i try (when window-system (require 'color-theme))
i get: Invalid function: (require (quote color-theme))
can i keep ' from getting evaluated to quote ? is there something else i can do?
scottj
proced is available on windows.
timcharper
scottj: proced is not available on MacOSX it would appear... or maybe I built emacs wrong
macrobat - what is the full context of what you are doing ?
(http://paste.lisp.org/)
it appears that using (when window-system (require 'color-theme)) would be passing window-system and (require 'color-theme) as arguments to the function when
it seems you may wish to use cond
(i'm no elisp guru though.. someone probably knows better)
macrobat
yes, ok i have more than one argument to pass, makes sense
ty
timcharper
oh....
wait
duh
no I get it
I've never used when... interesting. Usually use if and cond
that code evaluates just find on my machine
brb
bpalmer`
timcharper: when is a "built-in macro"; special forms are special.
paroneayea
what's the preferred way to do an http GET request in emacs?
bpalmer`
,http-get
fsbot
try: http-get.el HttpGet
« prev 1 2 3 4 5 6 7 8 next »