Custom indentation in Emacs Vhdl-mode

H

Hugo

Guest
Hello!
I hope some emacs guru can give me a tip on this :)
My organization requires that the following indentation is used in this
particular section of the code:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

Can I customize vhdl-mode to beautify like that to me?
The problem is that those 4 lines all return the same value in
"Syntactic Info" ( = statement), so I have no clue if what I want is
possible.

Any ideas?

Thanks,
Hugo
 
Hugo wrote:
Hello!
I hope some emacs guru can give me a tip on this :)
My organization requires that the following indentation is used in this
particular section of the code:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

Can I customize vhdl-mode to beautify like that to me?
yes

Any ideas?
I see that you also posted this to gun.emacs.help.
You will get an answer there.

-- Mike Treseler
 
"Mike Treseler" <mike_treseler@comcast.net> wrote in message
news:50n2phF1gkab9U1@mid.individual.net...
I see that you also posted this to gun.emacs.help.
You will get an answer there.
Surely mixing Emacs and firearms is a bad idea? Or did the editor wars just
escalate while I wasn't looking? :)

-Ben-
 
I think that must be forum for frustrated, suicidal emacs users...

Andy


Ben Jones wrote:
"Mike Treseler" <mike_treseler@comcast.net> wrote in message
news:50n2phF1gkab9U1@mid.individual.net...

I see that you also posted this to gun.emacs.help.
You will get an answer there.

Surely mixing Emacs and firearms is a bad idea? Or did the editor wars just
escalate while I wasn't looking? :)

-Ben-
 
Ben Jones wrote:
"Mike Treseler" <mike_treseler@comcast.net> wrote in message
news:50n2phF1gkab9U1@mid.individual.net...
I see that you also posted this to gun.emacs.help.
You will get an answer there.

Surely mixing Emacs and firearms is a bad idea?
Maybe not.
It passed the spell checker :)

-- Mike Treseler

"And I swear that I don't have a gnu."
 
On 11 Jan 2007 07:01:27 -0800, "Hugo" <hugows@gmail.com> wrote:

Hello!
I hope some emacs guru can give me a tip on this :)
My organization requires that the following indentation is used in this
particular section of the code:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

Can I customize vhdl-mode to beautify like that to me?
This is the obvious place for a script to delete the last two lines and
replace them with " use ieee.numeric_std;"

- Brian
 
Brian Drummond wrote:
On 11 Jan 2007 07:01:27 -0800, "Hugo" <hugows@gmail.com> wrote:

Hello!
I hope some emacs guru can give me a tip on this :)
My organization requires that the following indentation is used in this
particular section of the code:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

Can I customize vhdl-mode to beautify like that to me?

This is the obvious place for a script to delete the last two lines and
replace them with " use ieee.numeric_std;"
That's a positive twist for the editor wars.
While a macro to do a complete synopsys2numeric
is intractable, one to simply start on the
right foot by inserting

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

should not be difficult, and might
make for more interesting questions here.

I'll do such an emacs function
and will collect and post
any email contributions I get
in the next week for your favorite editor.

-- Mike Treseler
 
"Mike Treseler" <mike_treseler@comcast.net> wrote in message
news:50polbF1grf3jU1@mid.individual.net...
While a macro to do a complete synopsys2numeric
is intractable, one to simply start on the
right foot by inserting

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

should not be difficult, and might
make for more interesting questions here.
I know that when using CVS, and presumably other source code control
systems, it is possible to create custom scripts that refuse a check-in if
the file does not conform to certain rules. It would be good to have such a
rule for VHDL that would barf when presented with ieee.std_logic_unsigned
and friends.

Cheers,

-Ben-

....as for the editor wars, I am mostly in favour of gnu control. Although
most people in this newsgroup would be quick to defend our right to bear
ARMs...
 
So, any ideas on how to indent the use's relative to "library ieee" ? I
know it's pretty silly thing...

The only way I know to accomplish that would be a post-beautifier
function that fixes those lines.. but this sounds rather ugly... :)

Tks,
Hugo

Mike Treseler escreveu:

Brian Drummond wrote:
On 11 Jan 2007 07:01:27 -0800, "Hugo" <hugows@gmail.com> wrote:

Hello!
I hope some emacs guru can give me a tip on this :)
My organization requires that the following indentation is used in this
particular section of the code:

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

Can I customize vhdl-mode to beautify like that to me?

This is the obvious place for a script to delete the last two lines and
replace them with " use ieee.numeric_std;"

That's a positive twist for the editor wars.
While a macro to do a complete synopsys2numeric
is intractable, one to simply start on the
right foot by inserting

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

should not be difficult, and might
make for more interesting questions here.

I'll do such an emacs function
and will collect and post
any email contributions I get
in the next week for your favorite editor.

-- Mike Treseler
 
Hugo wrote:
So, any ideas on how to indent the use's relative to "library ieee" ? I
know it's pretty silly thing...

The only way I know to accomplish that would be a post-beautifier
function that fixes those lines.. but this sounds rather ugly... :)
Since I hijacked your thread, here's an idea.

Yes. If you look at the source for vhdl-beautify-buffer you will
see that it is pretty tightly wound. I would write a
wrapper function called vhdl-align-use that would
call beautify then find the first USE, insert three spaces, etc.
Something like:

(defun align-use () "Indent vhdl use clauses"
(vhdl-beautify-buffer)
(beginning-of-buffer)
;;code to search for "use" lines and insert three spaces goes here.
)
 
Ok, thanks! I guess that solution will do!

I thought I'd have to change the syntactic meaning of "use", but
vhdl-mode is kinda complicated (20k lines), so I probably don't want to
mess there anyway :)

Mike Treseler escreveu:

Hugo wrote:
So, any ideas on how to indent the use's relative to "library ieee" ? I
know it's pretty silly thing...

The only way I know to accomplish that would be a post-beautifier
function that fixes those lines.. but this sounds rather ugly... :)

Since I hijacked your thread, here's an idea.

Yes. If you look at the source for vhdl-beautify-buffer you will
see that it is pretty tightly wound. I would write a
wrapper function called vhdl-align-use that would
call beautify then find the first USE, insert three spaces, etc.
Something like:

(defun align-use () "Indent vhdl use clauses"
(vhdl-beautify-buffer)
(beginning-of-buffer)
;;code to search for "use" lines and insert three spaces goes here.
)
 
Mike Treseler wrote:

I'll do such an emacs function

(defun vhdl-ieee () "Insert ieee use clauses"
(interactive)
(insert "
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
"))


-- Mike Treseler
 
Mike Treseler <mike_treseler@comcast.net> writes:

Mike Treseler wrote:

I'll do such an emacs function


(defun vhdl-ieee () "Insert ieee use clauses"
(interactive)
(insert "
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
"))
And add this:
(define-key vhdl-template-map "\C-pi" 'vhdl-ieee)
to add it to the VHDL-template keymappings, (so you do C-c C-t C-p i
to insert it). Now I need to figure out how to get it onto the
menu...

Cheers,
Martin

--
martin.j.thompson@trw.com
TRW Conekt - Consultancy in Engineering, Knowledge and Technology
http://www.conekt.net/electronics.html
 
My apprach is a little different... I have a vhdl file template that is
inserted when I run "Insert header", and it already contains ieee
clauses, entity and architecture pairs, etc.

Cheers,
HS

On 26 jan, 11:17, Martin Thompson <martin.j.thomp...@trw.com> wrote:
Mike Treseler <mike_trese...@comcast.net> writes:
Mike Treseler wrote:

I'll do such an emacs function

(defun vhdl-ieee () "Insert ieee use clauses"
(interactive)
(insert "
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
"))And add this:
(define-key vhdl-template-map "\C-pi" 'vhdl-ieee)
to add it to the VHDL-template keymappings, (so you do C-c C-t C-p i
to insert it). Now I need to figure out how to get it onto the
menu...

Cheers,
Martin

--
martin.j.thomp...@trw.com
TRW Conekt - Consultancy in Engineering, Knowledge and Technologyhttp://www.conekt.net/electronics.html
 
Martin Thompson <martin.j.thompson@trw.com> writes:

Mike Treseler <mike_treseler@comcast.net> writes:

Mike Treseler wrote:

I'll do such an emacs function


(defun vhdl-ieee () "Insert ieee use clauses"
(interactive)
(insert "
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
"))

And add this:
(define-key vhdl-template-map "\C-pi" 'vhdl-ieee)
to add it to the VHDL-template keymappings, (so you do C-c C-t C-p i
to insert it).
Doh! What's actually required is this (after Mike's bit):

(add-hook 'vhdl-mode-hook
(lambda()
(define-key vhdl-template-map "\C-pi" 'vhdl-template-package-ieee)))

I'm sure a proper elisper would have a better way of doing it...

Cheers,
Martin

--
martin.j.thompson@trw.com
TRW Conekt - Consultancy in Engineering, Knowledge and Technology
http://www.conekt.net/electronics.html
 
HS wrote:
My approach is a little different... I have a vhdl file template that is
inserted when I run "Insert header", and it already contains ieee
clauses, entity and architecture pairs, etc.

Mike Treseler wrote:
(defun vhdl-ieee () "Insert ieee use clauses"
(interactive)
(insert "
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
"))

On 26 jan, 11:17, Martin Thompson wrote:
And add this:
(define-key vhdl-template-map "\C-pi" 'vhdl-ieee)
to add it to the VHDL-template keymappings, (so you do C-c C-t C-p i
to insert it). Now I need to figure out how to get it onto the
menu...

Thanks to HS and Martin for the vhdl-mode tips.
Looks like emacs wins round one 3 to nil :)

-- Mike Treseler
 

Welcome to EDABoard.com

Sponsor

Back
Top