Skip to contentSkip to conversation

PoC "make xconfig" Search Facility

PATCH In review Shlomi Fish 3 participants 6 messages Mar 27, 2006 – Apr 4, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PoC "make xconfig" Search Facility

Hi all!

[ I'm not subscribed to this list so please CC me on your replies. ]

This patch adds a proof-of-concept search facility to "make xconfig". Current problems and limitations:

1. Only case-insensitive single-substring search is supported.

2. The style is completely wrong, as I could not find a suitable vim configuration for editing Linux kernel source (and Google was not help). If anyone can refer me to one, I'll be grateful.

3. At the moment the results are displayed in a listbox as text. One cannot go from the result node to the place to toggle it in the configuration. (much less from one of it ancessorts)

But it works!

The patch is against kernel 2.6.16-git13.

Comments, suggestions, corrections, and flames are welcome.

Regards,

Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish [email protected]
Homepage: http://www.shlomifish.org/

95% of the programmers consider 95% of the code they did not write, in the bottom 5%.

kconfig/qconf.cc renamed from kconfig/qconf.cc.orig +111 -0
@@ -17,6 +17,10 @@
 #include <qheader.h>
 #include <qfiledialog.h>
 #include <qregexp.h>
+#include <qdialog.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
 
 #include <stdlib.h>
 
@@ -879,6 +883,8 @@
 	  connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
 	QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this);
 	  connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
+	QAction *findAction = new QAction("Find", QPixmap(xpm_save), "&Find", CTRL+Key_F, this);
+	  connect(findAction, SIGNAL(activated()), SLOT(findEntries()));
 
 	QAction *showNameAction = new QAction(NULL, "Show Name", 0, this);
 	  showNameAction->setToggleAction(TRUE);
@@ -925,6 +931,11 @@
 	config->insertSeparator();
 	quitAction->addTo(config);
 
+	// create file menu
+	QPopupMenu* editMenu = new QPopupMenu(this);
+	menu->insertItem("&Edit", editMenu);
+	findAction->addTo(editMenu);
+
 	// create options menu
 	QPopupMenu* optionMenu = new QPopupMenu(this);
 	menu->insertItem("&Option", optionMenu);
@@ -1138,6 +1149,106 @@
 		QMessageBox::information(this, "qconf", "Unable to save configuration!");
 }
 
+
+FindDialog::FindDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
+    : QDialog( parent, name, modal, fl )
+{
+    main_layout = new QVBoxLayout(this, 11, 6, "main_layout");
+    main_layout->addWidget(new QLabel("Query:", this, "label1"));
+    queryLineEdit = new QLineEdit(this, "queryLineEdit");
+    main_layout->addWidget(queryLineEdit);
+    findButton = new QPushButton("Find", this, "findButton");
+    main_layout->addWidget(findButton);
+    connect( findButton, SIGNAL( clicked() ), this, SLOT( performQuery() ) );
+    results = new QListBox(this, "results");
+    main_layout->addWidget(results);
+}
+
+FindDialog::~FindDialog()
+{
+}
+
+static QString * get_parent_disp(struct menu * menu)
+{
+    QString s;
+    if (menu->sym)
+    {
+        if (menu->prompt)
+        {
+            s += menu->prompt->text;
+            if (menu->sym->name)
+            {
+                s += " (";
+                s += menu->sym->name;
+                s += ")";
+            }
+        }
+        else if (menu->sym->name)
+        {
+            s += menu->sym->name;
+        }
+    }
+    else if (menu->prompt)
+    {
+        s += menu->prompt->text;
+    }
+    return new QString(s);
+}
+
+void FindDialog::search(QString & query, struct menu * mymenu, MenuList * parents)
+{
+    struct symbol * sym;
+    struct menu * child;
+    
+    MenuList new_parents(*parents);
+    new_parents.append(mymenu);
+
+    sym = mymenu->sym;
+
+    if (sym)
+    {
+        QString help(sym->help);
+        QString name(sym->name);
+        
+        if (help.contains(query, FALSE) || name.contains(query, FALSE))
+        {
+            MenuList::iterator it;
+            QString item;
+            for (it = parents->begin(); it != parents->end() ; ++it)
+            {
+                QString * parent_disp = get_parent_disp(*it);
+                item += *parent_disp;
+                item += " -> ";
+                delete parent_disp;
+            }
+            QString * disp = get_parent_disp(mymenu);
+            item += *disp;
+            delete disp;
+            results->insertItem(item);
+        }
+    }
+    for (child = mymenu->list; child ; child = child->next)
+    {
+        search(query, child, &new_parents);
+    }
+}
+
+void FindDialog::performQuery(void)
+{
+    QString query = queryLineEdit->text();
+    results->clear();
+    
+    MenuList parents;
+    search(query, &rootmenu, &parents);
+    // printf("Query for \"%s\"\n", (const char *)queryLineEdit->text());
+}
+
+void ConfigMainWindow::findEntries(void)
+{
+    FindDialog * dlg = new FindDialog(this, "dialog", TRUE);
+    dlg->exec();
+}
+
 void ConfigMainWindow::saveConfigAs(void)
 {
 	QString s = QFileDialog::getSaveFileName(".config", NULL, this);
kconfig/qconf.h renamed from kconfig/qconf.h.orig +21 -0
@@ -4,6 +4,7 @@
  */
 
 #include <qlistview.h>
+#include <qlistbox.h>
 #if QT_VERSION >= 300
 #include <qsettings.h>
 #else
@@ -229,6 +230,7 @@
 public slots:
 	void setHelp(QListViewItem* item);
 	void changeMenu(struct menu *);
+	void findEntries(void);
 	void listFocusChanged(void);
 	void goBack(void);
 	void loadConfig(void);
@@ -261,3 +263,22 @@
 
 	bool showDebug;
 };
+
+typedef QValueList<struct menu *> MenuList;
+
+class FindDialog : public QDialog
+{
+    Q_OBJECT
+public:
+    FindDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+    ~FindDialog();
+    QVBoxLayout * main_layout;
+    QLineEdit * queryLineEdit;
+    QPushButton * findButton;
+    QListBox * results;
+public slots:
+    void performQuery();
+public:
+    void search(QString & query, struct menu * mymenu, MenuList * parents);
+};
+
#1 lore raw
Quoted 4 lines · On Mon, 27 Mar 2006 21:50:41 +0200 Shlomi Fish wrote:

Hi all!

[ I'm not subscribed to this list so please CC me on your replies. ]

Quoted 8 lines

This patch adds a proof-of-concept search facility to "make xconfig". Current problems and limitations:

1. Only case-insensitive single-substring search is supported.

2. The style is completely wrong, as I could not find a suitable vim configuration for editing Linux kernel source (and Google was not help). If anyone can refer me to one, I'll be grateful.

I don't know of a vim config for kernel source code.
Just read/use Documentation/CodingStyle, although for this code that probably doesn't matter so much (since this isn't kernel run-time code).

Quoted 9 lines

3. At the moment the results are displayed in a listbox as text. One cannot go from the result node to the place to toggle it in the configuration. (much less from one of it ancessorts)

But it works!

The patch is against kernel 2.6.16-git13.

Comments, suggestions, corrections, and flames are welcome.

Thanks. It's useful and a good start.

A one-line comment about how to invoke it would have been nice:
Use Edit/Find or Ctrl-F to invoke the search (find) tool.

To be really useful it needs to display items that SELECT the search string IMO. Look at how menuconfig can do that.

E.g., for FW_LOADER (my favorite because it keeps me from disabling HOTPLUG so often), using /FW_LOADER in menuconfig tells me what SELECTs FW_LOADER as well as where it's defined.

Being able to enter more queries without leaving the dialog box is nice/good.

Oh, and patches should apply with 'patch -p1' (i.e., their filenames should begin with linux-tree/scripts/ etc., not with scripts/*).

---
~Randy

#2 lore raw
Quoted 8 lines · Randy.Dunlap
Quoted 7 lines · On Mon, 27 Mar 2006 21:50:41 +0200 Shlomi Fish wrote:

Hi all!

[ I'm not subscribed to this list so please CC me on your replies. ]

This patch adds a proof-of-concept search facility to "make xconfig". Current problems and limitations:

Quoted 7 lines
Quoted 5 lines

1. Only case-insensitive single-substring search is supported.

2. The style is completely wrong, as I could not find a suitable vim configuration for editing Linux kernel source (and Google was not help). If anyone can refer me to one, I'll be grateful.

I don't know of a vim config for kernel source code.

Too bad. :(

Quoted 2 lines

Just read/use Documentation/CodingStyle, although for this code that probably doesn't matter so much (since this isn't kernel run-time code).

Thing is when I enter tabs by default in Vim it uses 4 whitespace, and I need it to insert a real tab. This is just an example, I want to edit this in comfort.

Surely some kernel hackers use Vim, and someone must have come up with a vim config for editing kernel source.

Quoted 5 lines
Quoted 5 lines

3. At the moment the results are displayed in a listbox as text. One cannot go from the result node to the place to toggle it in the configuration. (much less from one of it ancessorts)

Quoted 7 lines
Quoted 5 lines

But it works!

The patch is against kernel 2.6.16-git13.

Comments, suggestions, corrections, and flames are welcome.

Thanks. It's useful and a good start.

Thanks.

Quoted 4 lines

A one-line comment about how to invoke it would have been nice:
Use Edit/Find or Ctrl-F to invoke the search (find) tool.

Where do you want this comment in? In the source code? In the application itself? Somewhere else?

Quoted 6 lines

To be really useful it needs to display items that SELECT the search string IMO. Look at how menuconfig can do that.

E.g., for FW_LOADER (my favorite because it keeps me from disabling HOTPLUG so often), using /FW_LOADER in menuconfig tells me what SELECTs FW_LOADER as well as where it's defined.

Yes, I realise that. Of course implementing it in "make xconfig" would be completely different than in "make menu config".

Quoted 6 lines

Being able to enter more queries without leaving the dialog box is nice/good.

Oh, and patches should apply with 'patch -p1' (i.e., their filenames should begin with linux-tree/scripts/ etc., not with scripts/*).

OK, I'll keep it in mind.

Regards,

Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish [email protected]
Homepage: http://www.shlomifish.org/

95% of the programmers consider 95% of the code they did not write, in the bottom 5%.

#3 lore raw
Quoted 22 lines · On Tue, 28 Mar 2006 21:53:04 +0200 Shlomi Fish wrote:
Quoted 8 lines · Randy.Dunlap
Quoted 7 lines · On Mon, 27 Mar 2006 21:50:41 +0200 Shlomi Fish wrote:

Hi all!

[ I'm not subscribed to this list so please CC me on your replies. ]

This patch adds a proof-of-concept search facility to "make xconfig". Current problems and limitations:

Quoted 7 lines
Quoted 5 lines

1. Only case-insensitive single-substring search is supported.

2. The style is completely wrong, as I could not find a suitable vim configuration for editing Linux kernel source (and Google was not help). If anyone can refer me to one, I'll be grateful.

I don't know of a vim config for kernel source code.

Too bad. :(

Quoted 2 lines

Just read/use Documentation/CodingStyle, although for this code that probably doesn't matter so much (since this isn't kernel run-time code).

Quoted 6 lines

Thing is when I enter tabs by default in Vim it uses 4 whitespace, and I need it to insert a real tab. This is just an example, I want to edit this in comfort.

Surely some kernel hackers use Vim, and someone must have come up with a vim config for editing kernel source.

Sure, lots of us do, but I'm not aware of an accepted vim config file for kernel work. My vim doesn't use spaces for tabs, e.g.
And there are a few source files in the kernel with vi(m) settings in them. Maybe that could help you.

Quoted 15 lines
Quoted 11 lines
Quoted 9 lines

3. At the moment the results are displayed in a listbox as text. One cannot go from the result node to the place to toggle it in the configuration. (much less from one of it ancessorts)

But it works!

The patch is against kernel 2.6.16-git13.

Comments, suggestions, corrections, and flames are welcome.

Thanks. It's useful and a good start.

Thanks.

Quoted 1 line
Quoted 6 lines
Quoted 3 lines

A one-line comment about how to invoke it would have been nice:
Use Edit/Find or Ctrl-F to invoke the search (find) tool.

Where do you want this comment in? In the source code? In the application itself? Somewhere else?

Oh, just in your email mainly. and in the source code could help also.

Quoted 9 lines
Quoted 6 lines

To be really useful it needs to display items that SELECT the search string IMO. Look at how menuconfig can do that.

E.g., for FW_LOADER (my favorite because it keeps me from disabling HOTPLUG so often), using /FW_LOADER in menuconfig tells me what SELECTs FW_LOADER as well as where it's defined.

Yes, I realise that. Of course implementing it in "make xconfig" would be completely different than in "make menu config".

Right, I just meant the use of it.

Quoted 7 lines
Quoted 5 lines

Being able to enter more queries without leaving the dialog box is nice/good.

Oh, and patches should apply with 'patch -p1' (i.e., their filenames should begin with linux-tree/scripts/ etc., not with scripts/*).

OK, I'll keep it in mind.

---
~Randy

#4 lore raw
Quoted 28 lines · Randy.Dunlap
Quoted 27 lines · On Tue, 28 Mar 2006 21:53:04 +0200 Shlomi Fish wrote:
Quoted 8 lines · Randy.Dunlap
Quoted 7 lines · On Mon, 27 Mar 2006 21:50:41 +0200 Shlomi Fish wrote:

Hi all!

[ I'm not subscribed to this list so please CC me on your replies. ]

This patch adds a proof-of-concept search facility to "make xconfig". Current problems and limitations:

Quoted 7 lines
Quoted 5 lines

1. Only case-insensitive single-substring search is supported.

2. The style is completely wrong, as I could not find a suitable vim configuration for editing Linux kernel source (and Google was not help). If anyone can refer me to one, I'll be grateful.

I don't know of a vim config for kernel source code.

Too bad. :(

Quoted 3 lines

Just read/use Documentation/CodingStyle, although for this code that probably doesn't matter so much (since this isn't kernel run-time code).

Thing is when I enter tabs by default in Vim it uses 4 whitespace, and I need it to insert a real tab. This is just an example, I want to edit this in comfort.

Quoted 7 lines
Quoted 2 lines

Surely some kernel hackers use Vim, and someone must have come up with a vim config for editing kernel source.

Sure, lots of us do, but I'm not aware of an accepted vim config file for kernel work. My vim doesn't use spaces for tabs, e.g.
And there are a few source files in the kernel with vi(m) settings in them. Maybe that could help you.

Thanks! I'll take a look.

Quoted 15 lines
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines

3. At the moment the results are displayed in a listbox as text. One cannot go from the result node to the place to toggle it in the configuration. (much less from one of it ancessorts)

Quoted 7 lines
Quoted 5 lines

But it works!

The patch is against kernel 2.6.16-git13.

Comments, suggestions, corrections, and flames are welcome.

Thanks. It's useful and a good start.

Thanks.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

A one-line comment about how to invoke it would have been nice:
Use Edit/Find or Ctrl-F to invoke the search (find) tool.

Where do you want this comment in? In the source code? In the application itself? Somewhere else?

Oh, just in your email mainly. and in the source code could help also.

I see. Well, I didn't see any comments for the other menu options. But I could add one for the new feature somewhere.

Quoted 12 lines
Quoted 9 lines
Quoted 6 lines

To be really useful it needs to display items that SELECT the search string IMO. Look at how menuconfig can do that.

E.g., for FW_LOADER (my favorite because it keeps me from disabling HOTPLUG so often), using /FW_LOADER in menuconfig tells me what SELECTs FW_LOADER as well as where it's defined.

Yes, I realise that. Of course implementing it in "make xconfig" would be completely different than in "make menu config".

Right, I just meant the use of it.

OK.

Regards,

Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish [email protected]
Homepage: http://www.shlomifish.org/

95% of the programmers consider 95% of the code they did not write, in the bottom 5%.

#5 lore raw
In reply to Shlomi Fish

On Mon, Mar 27, 2006 at 09:50:41PM +0200, Shlomi Fish took 238 lines to write:

Quoted 8 lines

Hi all!

[ I'm not subscribed to this list so please CC me on your replies. ]

This patch adds a proof-of-concept search facility to "make xconfig". Current problems and limitations:

1. Only case-insensitive single-substring search is supported.

That's a good start.

Quoted 3 lines

2. The style is completely wrong, as I could not find a suitable vim configuration for editing Linux kernel source (and Google was not help). If anyone can refer me to one, I'll be grateful.

Documentation/CodingStyle
scripts/Lindent

Kurt

Signature · 3 lines
Forgetfulness, n.:
	A gift of God bestowed upon debtors in compensation for their
destitution of conscience.