DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD Packages and Ports

OpenBSD Packages and Ports Installation and upgrading of packages and ports on OpenBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 4 Weeks Ago
Prevet Prevet is offline
Shell Scout
 
Join Date: Oct 2017
Posts: 111
Default Two very basic questions about readline(3) and indent(1)

Q1) I'm using rlwrap with ed(1) and want to add tabs while I'm editing. Since tab is used for completions I have altered my .inputrc file, so a tab character is inserted if ctrl-t is pressed, which is not the greatest. So I thought I'd ask if anyone here that uses readline with a CLI editor, can suggest a better alternative keypress, to get around the fact that the tab key is already taken.

Edit:
Forget that question. Maybe I can bind it to left or right alt or ctrl.

Q2) I want to try some C programming the OpenBSD way and have been reading the man for style(9). At the bottom it suggests a program called indent(1) which has a lot of options. So I was wondering if there is an OpenBSD specfic .indent.pro file uploaded somewhere with those settings. I searched and found one for Arch Linux, but could not find anything for OpenBSD. If there isn't an official one, perhaps you have seen one on Github?

Last edited by Prevet; 4 Weeks Ago at 02:44 PM.
Reply With Quote
  #2   (View Single Post)  
Old 4 Weeks Ago
ibara's Avatar
ibara ibara is offline
Real-life IT professor
 
Join Date: Jan 2014
Posts: 712
Default

Quote:
Originally Posted by Prevet View Post
Q1) I'm using rlwrap with ed(1) and want to add tabs while I'm editing. Since tab is used for completions I have altered my .inputrc file, so a tab character is inserted if ctrl-t is pressed, which is not the greatest. So I thought I'd ask if anyone here that uses readline with a CLI editor, can suggest a better alternative keypress, to get around the fact that the tab key is already taken.
Tab is ^I
Reply With Quote
  #3   (View Single Post)  
Old 4 Weeks Ago
Prevet Prevet is offline
Shell Scout
 
Join Date: Oct 2017
Posts: 111
Default

Thanks. So I could use "\C-i" as well as TAB.

I got it working a bit better. I made these changes to .inputrc to change the function TAB calls to tab-insert, only when ed is running.

# rlwrapped ed
$if rled
# complete with ctrl-t instead of tab
"\C-t": complete
# insert a tab character instead of complete
TAB: tab-insert
$endif

rlwrap is called with the flag
--command-name rled
So readline sees the above $if rled block.
Reply With Quote
  #4   (View Single Post)  
Old 4 Weeks Ago
ip6ix's Avatar
ip6ix ip6ix is offline
Real Name: Neil
Port Guard
 
Join Date: Sep 2017
Location: Wales, UK
Posts: 32
Default

According to style(9), the OpenBSD kernel source uses KNF (Kernel Normal Form) coding style, which is also referred to in the source for the indent(1) program in the OpenBSD base install. (See /usr/src/usr.bin/indent/README.)

So it's possible, likely even, that the default state for indent(1) is to reformat to KNF style without needing an ~/.indent.pro file at all.

I tested it on a couple of C source files I had lying around and the results look correct, but I'm not familiar enough with the KNF style to say for definite. Might be worth a shot though.
__________________
dc -e '[q]sa[ln0=aln256%Pln256/snlbx]sb12247225403800449909543746snlbxq'
Reply With Quote
  #5   (View Single Post)  
Old 3 Weeks Ago
Prevet Prevet is offline
Shell Scout
 
Join Date: Oct 2017
Posts: 111
Default

Quote:
Originally Posted by ip6ix View Post
According to style(9), the OpenBSD kernel source uses KNF (Kernel Normal Form) coding style, which is also referred to in the source for the indent(1) program in the OpenBSD base install. (See /usr/src/usr.bin/indent/README.)

So it's possible, likely even, that the default state for indent(1) is to reformat to KNF style without needing an ~/.indent.pro file at all.

I tested it on a couple of C source files I had lying around and the results look correct, but I'm not familiar enough with the KNF style to say for definite. Might be worth a shot though.
I had a go at it and found almost all of the default settings were fine, except the spacing after variable declarations were double tabs, and the case statements weren't right on default.

So these are the settings I ended up changing:
-ci4
-cli0
-di1

You also have to tell it about your typedefs and structs using the -T flag:
-Tnameoftypedef1
-Tnameoftypedef2
...

Other than that, I couldn't see a flag for the way OpenBSD does spacing of variable declarations inside of structs, so that part has to be done by hand.
Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenBSD Installer / Install Script Basic Questions daemonbak OpenBSD Installation and Upgrading 9 28th May 2015 01:56 AM
Some basic questions regarding pkgsrc use gezley NetBSD Package System (pkgsrc) 15 30th April 2015 04:25 PM
openbsd basic questions barti OpenBSD General 12 17th July 2012 08:38 PM
basic rsync questions unixjingleman FreeBSD General 5 27th May 2011 04:39 AM
Basic starter questions ??? dennky OpenBSD Installation and Upgrading 10 5th December 2009 07:21 PM


All times are GMT. The time now is 08:22 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick