* Modifying many function calls
@ 2010-10-26 8:44 Andrea Crotti
2010-10-26 9:55 ` Andrea Crotti
0 siblings, 1 reply; 11+ messages in thread
From: Andrea Crotti @ 2010-10-26 8:44 UTC (permalink / raw)
To: help-gnu-emacs
I would like to finally prepend a prefix to all my personal functions.
Since they are 80 at the moment I would like to do it automatically.
For the (defun fun) part is easy, but what about all the places when
they are called?
I should loop on all the
(defun fun) and substitute all the occurrences of fun every time, what's
the best way to do it with Emacs?
Thanks,
Andrea
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Modifying many function calls
2010-10-26 8:44 Modifying many function calls Andrea Crotti
@ 2010-10-26 9:55 ` Andrea Crotti
2010-10-26 19:07 ` Glauber Alex Dias Prado
2010-10-27 8:11 ` Andreas Röhler
0 siblings, 2 replies; 11+ messages in thread
From: Andrea Crotti @ 2010-10-26 9:55 UTC (permalink / raw)
To: help-gnu-emacs
Andrea Crotti <andrea.crotti.0@gmail.com> writes:
> I would like to finally prepend a prefix to all my personal functions.
> Since they are 80 at the moment I would like to do it automatically.
>
> For the (defun fun) part is easy, but what about all the places when
> they are called?
>
> I should loop on all the
> (defun fun) and substitute all the occurrences of fun every time, what's
> the best way to do it with Emacs?
>
> Thanks,
> Andrea
I was also seeing if semantic can help, but if I go on any of the
functions and I try
M-x RET semantic-symref, I don't anything, even if there are actually
calls to that function and semantic is working fine.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Modifying many function calls
[not found] <mailman.5.1288082692.1069.help-gnu-emacs@gnu.org>
@ 2010-10-26 13:42 ` Ted Zlatanov
0 siblings, 0 replies; 11+ messages in thread
From: Ted Zlatanov @ 2010-10-26 13:42 UTC (permalink / raw)
To: help-gnu-emacs
On Tue, 26 Oct 2010 10:44:17 +0200 Andrea Crotti <andrea.crotti.0@gmail.com> wrote:
AC> I would like to finally prepend a prefix to all my personal functions.
AC> Since they are 80 at the moment I would like to do it automatically.
AC> For the (defun fun) part is easy, but what about all the places when
AC> they are called?
AC> I should loop on all the
AC> (defun fun) and substitute all the occurrences of fun every time, what's
AC> the best way to do it with Emacs?
You could use `make-obsolete' on the old symbol and `defalias' to make
the new one. Then byte-compiling will warn about the obsolete function.
Personally I would just use `grep' or `ack' coupled with
"perl -p -i -e's/OLD/NEW/g' *.el" coupled with version control :)
Ted
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Modifying many function calls
2010-10-26 9:55 ` Andrea Crotti
@ 2010-10-26 19:07 ` Glauber Alex Dias Prado
2010-10-27 8:11 ` Andreas Röhler
1 sibling, 0 replies; 11+ messages in thread
From: Glauber Alex Dias Prado @ 2010-10-26 19:07 UTC (permalink / raw)
To: Andrea Crotti; +Cc: help-gnu-emacs
the easiest but perhaps not the best is replace-string there is also
some command that can do the same but recursing on a dir, i dont
remember which.
Andrea Crotti <andrea.crotti.0@gmail.com> writes:
> Andrea Crotti <andrea.crotti.0@gmail.com> writes:
>
>> I would like to finally prepend a prefix to all my personal functions.
>> Since they are 80 at the moment I would like to do it automatically.
>>
>> For the (defun fun) part is easy, but what about all the places when
>> they are called?
>>
>> I should loop on all the
>> (defun fun) and substitute all the occurrences of fun every time, what's
>> the best way to do it with Emacs?
>>
>> Thanks,
>> Andrea
>
> I was also seeing if semantic can help, but if I go on any of the
> functions and I try
> M-x RET semantic-symref, I don't anything, even if there are actually
> calls to that function and semantic is working fine.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Modifying many function calls
2010-10-26 9:55 ` Andrea Crotti
2010-10-26 19:07 ` Glauber Alex Dias Prado
@ 2010-10-27 8:11 ` Andreas Röhler
2010-10-27 10:16 ` Andrea Crotti
[not found] ` <mailman.1.1288174667.7486.help-gnu-emacs@gnu.org>
1 sibling, 2 replies; 11+ messages in thread
From: Andreas Röhler @ 2010-10-27 8:11 UTC (permalink / raw)
To: help-gnu-emacs
Am 26.10.2010 11:55, schrieb Andrea Crotti:
> Andrea Crotti<andrea.crotti.0@gmail.com> writes:
>
>> I would like to finally prepend a prefix to all my personal functions.
>> Since they are 80 at the moment I would like to do it automatically.
>>
>> For the (defun fun) part is easy, but what about all the places when
>> they are called?
>>
>> I should loop on all the
>> (defun fun) and substitute all the occurrences of fun every time, what's
>> the best way to do it with Emacs?
>>
>> Thanks,
>> Andrea
>
> I was also seeing if semantic can help, but if I go on any of the
> functions and I try
> M-x RET semantic-symref, I don't anything, even if there are actually
> calls to that function and semantic is working fine.
>
>
>
Hi,
wrote years ago the opposite: defining aliases for all prefixed
functions, The alias then was the function name with prefix turned into
suffix. Should exist in the gnu-emacs-sources@gnu.org archive somewhere.
Purpose was making completion of function-groups work.
However, would write that differently today probably.
Also, if you give some info here, it should be possible to put the
script together at this list.
Questions would be:
- reside all files with functions to rename in the same directory?
- really all functions to rename?
- only functions to rename, not variables?
Andreas
--
https://code.launchpad.net/~a-roehler/python-mode/python-mode-components
https://code.launchpad.net/s-x-emacs-werkstatt/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Modifying many function calls
2010-10-27 8:11 ` Andreas Röhler
@ 2010-10-27 10:16 ` Andrea Crotti
2010-10-27 11:09 ` Andreas Röhler
` (2 more replies)
[not found] ` <mailman.1.1288174667.7486.help-gnu-emacs@gnu.org>
1 sibling, 3 replies; 11+ messages in thread
From: Andrea Crotti @ 2010-10-27 10:16 UTC (permalink / raw)
To: help-gnu-emacs
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> Hi,
>
> wrote years ago the opposite: defining aliases for all prefixed
> functions, The alias then was the function name with prefix turned
> into suffix. Should exist in the gnu-emacs-sources@gnu.org archive
> somewhere.
>
> Purpose was making completion of function-groups work.
> However, would write that differently today probably.
>
> Also, if you give some info here, it should be possible to put the
> script together at this list.
>
> Questions would be:
>
> - reside all files with functions to rename in the same directory?
> - really all functions to rename?
> - only functions to rename, not variables?
- actually in the same big org-mode file (unless I call something from
some yasnippet snippet, but I don't think)
- yes maybe also variables
But variables can be assigned to a group also (with defcustom) so it's
not so bad
- yes really all functions (some have the "my-" prefix but that can be
changed easily I think)
And since I'm here, why I can't redefine a variable with defcustom?
I mean if I do
(defcustom x 1)
then I want to change it
and I write and evaluate
(defcustom x 2)
then even if I set it to nil and the reevaluate again still it doesn't
care.
Is that normal?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Modifying many function calls
2010-10-27 10:16 ` Andrea Crotti
@ 2010-10-27 11:09 ` Andreas Röhler
2010-10-27 14:24 ` redefining/re-evaluating a defcustom [was: Modifying many function calls] Drew Adams
2010-10-27 13:05 ` Modifying many function calls Andreas Röhler
2010-10-28 2:56 ` PJ Weisberg
2 siblings, 1 reply; 11+ messages in thread
From: Andreas Röhler @ 2010-10-27 11:09 UTC (permalink / raw)
To: help-gnu-emacs
[ ... ]
> And since I'm here, why I can't redefine a variable with defcustom?
> I mean if I do
>
> (defcustom x 1)
> then I want to change it
> and I write and evaluate
> (defcustom x 2)
>
> then even if I set it to nil and the reevaluate again still it doesn't
> care.
> Is that normal?
>
>
>
>
AFAIK yes. It's little bit like with `defvar', but not that strictly,
rather unpredictable.
Use `setq', resp. a setq afterwards to make sure the new value is taken.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Modifying many function calls
2010-10-27 10:16 ` Andrea Crotti
2010-10-27 11:09 ` Andreas Röhler
@ 2010-10-27 13:05 ` Andreas Röhler
2010-10-28 2:56 ` PJ Weisberg
2 siblings, 0 replies; 11+ messages in thread
From: Andreas Röhler @ 2010-10-27 13:05 UTC (permalink / raw)
To: help-gnu-emacs
Am 27.10.2010 12:16, schrieb Andrea Crotti:
> Andreas Röhler<andreas.roehler@easy-emacs.de> writes:
>
>> Hi,
>>
>> wrote years ago the opposite: defining aliases for all prefixed
>> functions, The alias then was the function name with prefix turned
>> into suffix. Should exist in the gnu-emacs-sources@gnu.org archive
>> somewhere.
>>
>> Purpose was making completion of function-groups work.
>> However, would write that differently today probably.
>>
>> Also, if you give some info here, it should be possible to put the
>> script together at this list.
>>
>> Questions would be:
>>
>> - reside all files with functions to rename in the same directory?
>> - really all functions to rename?
>> - only functions to rename, not variables?
>
> - actually in the same big org-mode file
(?) assume "directory"
In any case, suggest to move your functions into a separate directory or
file.
That would make things much easier.
Unless there are reason not to do this.
If in a directory, first task is to get a list of files.
Function below as an example messaging in:
(defun load-files-from-directory (&optional dir)
(interactive)
(let* ((dir (or dir default-directory))
(files (directory-files (expand-file-name
(substitute-in-file-name dir)) t "\\.el$")))
(message "%s" files)))
If just one file, its even easier, we proceed there.
(unless I call something from
> some yasnippet snippet, but I don't think)
> - yes maybe also variables
> But variables can be assigned to a group also (with defcustom) so it's
> not so bad
> - yes really all functions (some have the "my-" prefix but that can be
> changed easily I think)
[ ... ]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Modifying many function calls
[not found] ` <mailman.1.1288174667.7486.help-gnu-emacs@gnu.org>
@ 2010-10-27 13:40 ` Scott Frazer
0 siblings, 0 replies; 11+ messages in thread
From: Scott Frazer @ 2010-10-27 13:40 UTC (permalink / raw)
To: help-gnu-emacs
On 10/27/10 6:16 AM, Andrea Crotti wrote:
> Andreas Röhler<andreas.roehler@easy-emacs.de> writes:
>
> And since I'm here, why I can't redefine a variable with defcustom?
> I mean if I do
>
> (defcustom x 1)
> then I want to change it
> and I write and evaluate
> (defcustom x 2)
>
> then even if I set it to nil and the reevaluate again still it doesn't
> care.
> Is that normal?
>
You need to use eval-defun on defvar's and defcustom's, bound to C-M-x by default.
^ permalink raw reply [flat|nested] 11+ messages in thread
* redefining/re-evaluating a defcustom [was: Modifying many function calls]
2010-10-27 11:09 ` Andreas Röhler
@ 2010-10-27 14:24 ` Drew Adams
0 siblings, 0 replies; 11+ messages in thread
From: Drew Adams @ 2010-10-27 14:24 UTC (permalink / raw)
To: 'Andreas Röhler', help-gnu-emacs
> > why I can't redefine a variable with defcustom? I mean if I do
> >
> > (defcustom x 1) then I want to change it
> > and I write and evaluate (defcustom x 2)
> >
> > then even if I set it to nil and the reevaluate again still
> > it doesn't care. Is that normal?
>
> AFAIK yes. It's little bit like with `defvar', but not that strictly,
> rather unpredictable.
I think it's completely predictable. Yes, it's like `defvar'.
> Use `setq' ... to make sure the new value is taken.
Interactively, you can just put point inside the defcustom somewhere and hit
`C-M-x'.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Modifying many function calls
2010-10-27 10:16 ` Andrea Crotti
2010-10-27 11:09 ` Andreas Röhler
2010-10-27 13:05 ` Modifying many function calls Andreas Röhler
@ 2010-10-28 2:56 ` PJ Weisberg
2 siblings, 0 replies; 11+ messages in thread
From: PJ Weisberg @ 2010-10-28 2:56 UTC (permalink / raw)
To: help-gnu-emacs
On Wed, Oct 27, 2010 at 10:16 AM, Andrea Crotti
<andrea.crotti.0@gmail.com> wrote:
> And since I'm here, why I can't redefine a variable with defcustom?
> I mean if I do
>
> (defcustom x 1)
> then I want to change it
> and I write and evaluate
> (defcustom x 2)
>
> then even if I set it to nil and the reevaluate again still it doesn't
> care.
> Is that normal?
If the user has already customized x to some value (nil or anything
else), then you don't want the default value to overwrite it. So
defcustom avoids setting the value if it's already been set.
(Note that if x is a buffer-local variable with no global value,
defcustom will set the global default value without changing the local
value.)
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-10-28 2:56 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-26 8:44 Modifying many function calls Andrea Crotti
2010-10-26 9:55 ` Andrea Crotti
2010-10-26 19:07 ` Glauber Alex Dias Prado
2010-10-27 8:11 ` Andreas Röhler
2010-10-27 10:16 ` Andrea Crotti
2010-10-27 11:09 ` Andreas Röhler
2010-10-27 14:24 ` redefining/re-evaluating a defcustom [was: Modifying many function calls] Drew Adams
2010-10-27 13:05 ` Modifying many function calls Andreas Röhler
2010-10-28 2:56 ` PJ Weisberg
[not found] ` <mailman.1.1288174667.7486.help-gnu-emacs@gnu.org>
2010-10-27 13:40 ` Scott Frazer
[not found] <mailman.5.1288082692.1069.help-gnu-emacs@gnu.org>
2010-10-26 13:42 ` Ted Zlatanov
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 read-only IMAP folder(s) and NNTP newsgroup(s).