Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Custom indentation in Emacs Vhdl-mode

Reply
Thread Tools

Custom indentation in Emacs Vhdl-mode

 
 
haws
Guest
Posts: n/a
 
      01-12-2007
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.
> )


 
Reply With Quote
 
 
 
 
Mike Treseler
Guest
Posts: n/a
 
      01-25-2007
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
 
Reply With Quote
 
 
 
 
Martin Thompson
Guest
Posts: n/a
 
      01-26-2007
Mike Treseler <(E-Mail Removed)> 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

--
http://www.velocityreviews.com/forums/(E-Mail Removed)
TRW Conekt - Consultancy in Engineering, Knowledge and Technology
http://www.conekt.net/electronics.html


 
Reply With Quote
 
HS
Guest
Posts: n/a
 
      01-26-2007
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 <(E-Mail Removed)> wrote:
> Mike Treseler <(E-Mail Removed)> 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
>
> --
> (E-Mail Removed)
> TRW Conekt - Consultancy in Engineering, Knowledge and Technologyhttp://www.conekt.net/electronics.html


 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      01-26-2007
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
 
Reply With Quote
 
Martin Thompson
Guest
Posts: n/a
 
      01-29-2007
Martin Thompson <(E-Mail Removed)> writes:

> Mike Treseler <(E-Mail Removed)> 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

--
(E-Mail Removed)
TRW Conekt - Consultancy in Engineering, Knowledge and Technology
http://www.conekt.net/electronics.html


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
remove overall indentation preserving reletive indentation Jesse B. Ruby 2 03-27-2010 07:23 PM
Question about emacs indentation Sam Kong Ruby 8 08-30-2005 04:00 PM
automatic nesting and indentation in emacs porterboy Python 3 02-25-2005 01:54 PM
Emacs Ruby mode & indentation with the tab key wish/bug Moritz Bunkus Ruby 4 06-17-2004 02:12 PM
Python indentation for Ruby under Emacs Xavier Noria Ruby 1 08-24-2003 08:39 PM



Advertisments