Custom indentation in Emacs Vhdl-mode

Discussion in 'VHDL' started by Hugo, Jan 11, 2007.

  1. Hugo

    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, Jan 11, 2007
    #1
    1. Advertising

  2. 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, Jan 11, 2007
    #2
    1. Advertising

  3. Hugo

    Ben Jones Guest

    "Mike Treseler" <> wrote in message
    news:...
    >
    > 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, Jan 11, 2007
    #3
  4. Hugo

    Andy Guest

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

    Andy


    Ben Jones wrote:
    > "Mike Treseler" <> wrote in message
    > news:...
    > >
    > > 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-
     
    Andy, Jan 11, 2007
    #4
  5. Ben Jones wrote:
    > "Mike Treseler" <> wrote in message
    > news:...
    >> 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."
     
    Mike Treseler, Jan 11, 2007
    #5
  6. On 11 Jan 2007 07:01:27 -0800, "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?


    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, Jan 12, 2007
    #6
  7. Brian Drummond wrote:
    > On 11 Jan 2007 07:01:27 -0800, "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?

    >
    > 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, Jan 12, 2007
    #7
  8. Hugo

    Ben Jones Guest

    "Mike Treseler" <> wrote in message
    news:...
    > 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...
     
    Ben Jones, Jan 12, 2007
    #8
  9. Hugo

    Hugo Guest

    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" <> 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, Jan 12, 2007
    #9
  10. 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, Jan 12, 2007
    #10
  11. Hugo

    haws Guest

    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.
    > )
     
    haws, Jan 12, 2007
    #11
  12. 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, Jan 25, 2007
    #12
  13. Mike Treseler <> 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

    --

    TRW Conekt - Consultancy in Engineering, Knowledge and Technology
    http://www.conekt.net/electronics.html
     
    Martin Thompson, Jan 26, 2007
    #13
  14. Hugo

    HS Guest

    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 <> wrote:
    > Mike Treseler <> 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
    >
    > --
    >
    > TRW Conekt - Consultancy in Engineering, Knowledge and Technologyhttp://www.conekt.net/electronics.html
     
    HS, Jan 26, 2007
    #14
  15. 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
     
    Mike Treseler, Jan 26, 2007
    #15
  16. Martin Thompson <> writes:

    > Mike Treseler <> 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

    --

    TRW Conekt - Consultancy in Engineering, Knowledge and Technology
    http://www.conekt.net/electronics.html
     
    Martin Thompson, Jan 29, 2007
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. omara007
    Replies:
    0
    Views:
    1,480
    omara007
    Jan 6, 2010
  2. Moritz Bunkus
    Replies:
    4
    Views:
    278
    Moritz Bunkus
    Jun 17, 2004
  3. Jeffrey Moss

    eruby mode emacs with mmm-mode

    Jeffrey Moss, Jul 6, 2005, in forum: Ruby
    Replies:
    1
    Views:
    149
    Alan Chen
    Jul 6, 2005
  4. Jesse B.
    Replies:
    2
    Views:
    193
    Josh Cheek
    Mar 27, 2010
  5. PerlFAQ Server
    Replies:
    1
    Views:
    195
    Marc Girod
    Jan 8, 2011
Loading...

Share This Page