Warning, /sdk/kde-dev-scripts/kde-emacs/klaralv.el is written in an unsupported language. File is not indexed.
0001 ;; ------------------------------ COPYRIGHT NOTICE ------------------------------ 0002 ;; klaralv.el version 1.4 0003 ;; Copyright Klaralvdalens Datakonsult AB. 0004 ;; 0005 ;; This program is free software; you can redistribute it and/or modify it 0006 ;; under the terms of the GNU General Public License as published by the Free 0007 ;; Software Foundation; either version 2 of the License, or (at your option) 0008 ;; any later version. 0009 ;; 0010 ;; This program is distributed in the hope that it will be useful, but 0011 ;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 0012 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0013 ;; for more details. 0014 ;; 0015 ;; You should have received a copy of the GNU General Public License along 0016 ;; with GNU Emacs. If you did not, write to the Free Software Foundation, 0017 ;; Inc., 51 Franklin Street, Fifth Floor., Boston, MA 02110-1301, USA. 0018 0019 0020 ;; ------------------------------ INSTALLATION ------------------------------ 0021 ;; To use this file, put this file in your emacs config directory. 0022 ;; If you do not have such a directory, create one and add 0023 ;; something like the following to your .emacs: 0024 ;; (setq load-path (cons "/home/joe/Emacs/" load-path)) 0025 ;; 0026 ;; Next insert the following line into your .emacs 0027 ;; (require 'klaralv) 0028 ;; (global-set-key [(f5)] 'kdab-insert-header) 0029 ;; (global-set-key [(shift f5)] 'kdab-insert-forward-decl) 0030 ;; (global-set-key [(control f5)] 'kdab-lookup-qt-documentation) 0031 ;; 0032 ;; If you use Qtopia, insert the following line to activate Qtopia headers 0033 ;; (setq kdab-include-qpe 't) 0034 ;; If you do not want include files to be prefixed with qtopia/, 0035 ;; as in qtopia/qpeapplication, then insert the following code in your setup 0036 ;; (setq kdab-prefix-qpe nil) 0037 ;; 0038 ;; If you are using Qt 3 rather than Qt 4, insert the following line into you setup: 0039 ;; (setq kdab-qt-version 3) 0040 ;; or in a .emacs-dirvars file: 0041 ;; kdab-qt-version: 3 0042 ;; 0043 ;; Finally, if you do not want header files to be inserted lower-cased when 0044 ;; not found locally, insert (kdab-lowercase-header-files nil) 0045 0046 (require 'kdab-qstring) 0047 0048 ;; ------------------------------ CONFIGURATION ------------------------------ 0049 (defvar kdab-qt-version 4 0050 "Specify which header files to use") 0051 0052 (defvar kdab-include-qpe nil 0053 "Specifies whether Qtopia headers should be included") 0054 0055 (defvar kdab-prefix-qpe 't 0056 "set this to nil if you do not want QTopia header files prefixed with qtopia/") 0057 0058 (defvar kdab-lowercase-header-files 't 0059 "Should header files be all lowercase, or would you prefer to use same case as class?") 0060 0061 (defvar kdab-private-special-includes '() 0062 "Override variable for special include specifications") 0063 0064 (defvar kdab-suffix-for-private-headers "_p\\|_priv" 0065 "Regular expression specifying the possible suffix to a file name for private includes. 0066 The default regular expression allows that a file named test.cpp may include test_p.h or test_priv.h. 0067 This is used when inserting headers, to ensure that no includes are inserted before the private header") 0068 0069 ;; ------------------------------ Include Specifications ------------------------------ 0070 ;; special case for include files 0071 ;; Please notify blackie@klaralvdalens-datakonsult.se with any modification to this variable! 0072 (defvar kdab-special-includes 0073 '( 0074 ; KDE 0075 (kdebug.h kDebug kWarning kError kFatal kBacktrace kdDebug kdWarning kdError kdFatal kdBacktrace) 0076 (kicondialog.h KIconCanvas KIconButton) 0077 (knuminput.h KDoubleNumInput KIntNumInput) 0078 0079 ; KDGear - http://www.klaralvdalens-datakonsult.se 0080 (KDCheckableGroupBox.h KDCheckableGroupBox) 0081 (KDCheckableHGroupBox.h KDCheckableHGroupBox) 0082 (KDCheckableVGroupBox.h KDCheckableVGroupBox) 0083 (KDCloseableWidget.h KDCloseableWidget) 0084 (KDConfigDialog.h KDConfigDialog) 0085 (KDConfigWidget.h KDConfigWidget) 0086 (KDDateWidget.h KDDateWidget KDDateTimeWidget) 0087 (KDDirMonitor.h KDDirMonitor) 0088 (KDGridWidget.h KDGridWidget) 0089 (KDListBoxPair.h KDListBoxPair) 0090 (KDMinimizeSplitter.h KDMinimizeSplitter) 0091 (KDSearchableListBox.h KDSearchableListBox) 0092 (KDSemiSizingControl.h KDSemiSizingControl) 0093 (KDShowHideTableControl.h KDShowHideTableControl) 0094 (KDSimpleSizingControl.h KDSimpleSizingControl) 0095 (KDSizingControl.h KDSizingControl) 0096 (KDStream.h KDStream) 0097 (KDTimeWidget.h KDTimeWidget) 0098 0099 ; KDChart - http://www.klaralvdalens-datakonsult.se 0100 (KDChart.h KDChart) 0101 (KDChartAxisParams.h KDChartAxisParams) 0102 (KDChartBaseSeries.h KDChartBaseSeries) 0103 (KDChartCustomBox.h KDChartCustomBox) 0104 (KDChartData.h KDChartData) 0105 (KDChartEnums.h KDChartEnums) 0106 (KDChartListTable.h KDChartListTableData KDChartListTablePrivate) 0107 (KDChartNotEnoughSpaceException.h KDChartNotEnoughSpaceException) 0108 (KDChartPainter.h KDChartPainter) 0109 (KDChartParams.h KDChartFrameSettings KDChartParams ModeAndChart) 0110 (KDChartPlaneSeries.h KDChartPlaneSeries) 0111 (KDChartPropertySet.h KDChartPropertySet) 0112 (KDChartSeriesCollection.h KDChartSeriesCollection) 0113 (KDChartTable.h KDChartTableData) 0114 (KDChartTableBase.h KDChartTableDataBase) 0115 (KDChartTextPiece.h KDChartTextPiece) 0116 (KDChartUnknownTypeException.h KDChartUnknownTypeException) 0117 (KDChartVectorSeries.h KDChartVectorSeries) 0118 (KDChartVectorTable.h KDChartVectorTableData KDChartVectorTablePrivate) 0119 (KDChartWidget.h KDChartWidget) 0120 (KDFrame.h KDFrame KDFrameCorner) 0121 (KDFrameProfileSection.h KDFrameProfileSection) 0122 0123 ; Useful fake entries 0124 (kapplication.h kapp) 0125 (klocale.h i18n i18nc i18ncp i18np I18N_NOOP) 0126 (kstandarddirs.h locate locateLocal) 0127 (stdlib.h getenv) 0128 (unistd.h unlink sleep usleep) 0129 (iostream cout cerr) 0130 (ctype.h isalnum isalpha isascii isblank iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit) 0131 (string.h strcpy strlen memcpy strerror) 0132 (stdlib.h atoi atol) 0133 ) 0134 "List of special include files which do not follow the normal scheme") 0135 0136 (defvar kdab-qt3-special-includes 0137 '((qlayout.h QHBoxLayout QVBoxLayout QGridLayout QBoxLayout) 0138 (qlistview.h QListViewItem QCheckListItem QListViewItemIterator) 0139 (qiconview.h QIconViewItem QIconDragItem QIconDrag) 0140 (qdragobject.h QTextDrag QStoredDrag QUriDag QColorDrag QImageDrag QDragManager) 0141 (qmime.h QMimeSource QMimeSourceFactory QWindowsMime) 0142 (qptrlist.h QPtrListIterator) 0143 (qevent.h QTimerEvent QMouseEvent QWheelEvent QTabletEvent QKeyEvent 0144 QFocusEvent QPaintEvent QMoveEvent QResizeEvent QCloseEvent 0145 QShowEvent QHideEvent QContextMenuEvent QIMEvent QDropEvent 0146 QDragMoveEvent QDragEnterEvent QDragResponseEvent QDragLeaveEvent 0147 QChildEvent QCustomEvent) 0148 (qdatetime.h QTime QDateTime QDate) 0149 (qdatetimeedit.h QTimeEdit QDateTimeEditBase QDateEdit QDateTimeEdit) 0150 (qcstring.h QByteArray) 0151 (qobjectlist.h QObjectListIt QObjectListIterator) 0152 (qwidgetlist.h QWidgetListIt) 0153 (qtabbar.h QTab) 0154 (qpalette.h QColorGroup) 0155 (qaction.h QActionGroup) 0156 (qvalidator.h QIntValidator QDoubleValidator QRegExpValidator) 0157 (qlistbox.h QListBoxItem QListBoxText QListBoxPixmap) 0158 (qstring.h QChar QCharRef QConstString) 0159 (qcanvas.h QCanvasSprite QCanvasPolygonalItem QCanvasRectangle 0160 QCanvasPolygon QCanvasEllipse QCanvasText QCanvasLine 0161 QCanvasChunk QCanvas QCanvasItem QCanvasView QCanvasPixmap) 0162 (qgl.h QGLFormat QGL QGLContext QGLWidget QGLColormap) 0163 (qtable.h QTableSelection QTableItem QComboTableItem QCheckTableItem) 0164 (qsqlfield.h QSqlField QSqlFieldInfo) 0165 (qsqlrecord.h QSqlRecord QSqlRecordInfo) 0166 0167 ; Qt/Embedded 0168 (qcopchannel_qws.h QCopChannel) 0169 (qdirectpainter_qws.h QDirectPainter) 0170 (qfontfactorybdf_qws.h QFontFactoryBDF) 0171 (qfontfactoryttf_qws.h QFontFactoryFT) 0172 (qfontmanager_qws.h QGlyphMetrics QGlyph QRenderedFont QDiskFont QFontManager QFontFactory) 0173 (qgfx_qws.h QScreenCursor QPoolEntry QScreen QGfx) 0174 (qgfxlinuxfb_qws.h QLinuxFbScreen) 0175 (qgfxmatroxdefs_qws.h QQnxFbGfx QQnxScreen) 0176 (qgfxraster_qws.h QGfxRasterBase QGfxRaster) 0177 (qgfxvnc_qws.h QRfbRect QRfbPixelFormat QRfbServerInit QRfbSetEncodings 0178 QRfbFrameBufferUpdateRequest QRfbKeyEvent QRfbPointerEvent QRfbClientCutText QVNCServer) 0179 (qkeyboard_qws.h QWSKeyboardHandler) 0180 (qlock_qws.h QLock QLockHolder) 0181 (qmemorymanager_qws.h QMemoryManagerPixmap QMemoryManager) 0182 (qsoundqss_qws.h QWSSoundServer QWSSoundClient QWSSoundServerClient QWSSoundServerSocket) 0183 (qwindowsystem_qws.h QWSInternalWindowInfo QWSScreenSaver QWSWindow QWSSoundServer 0184 QWSServer qwsServer KeyboardFilter QWSClient) 0185 (qwsbeosdecoration_qws.h QWSBeOSDecoration) 0186 (qwscursor_qws.h QWSCursor) 0187 (qwsdecoration_qws.h QWSDecoration) 0188 (qwsdefaultdecoration_qws.h QWSDefaultDecoration) 0189 (qwsdisplay_qws.h QWSWindowInfo QWSDisplay) 0190 (qwshydrodecoration_qws.h QWSHydroDecoration) 0191 (qwskde2decoration_qws.h QWSKDE2Decoration) 0192 (qwskdedecoration_qws.h QWSKDEDecoration) 0193 (qwsmanager_qws.h QWSManager QWSButton) 0194 (qwsmouse_qws.h QWSPointerCalibrationData QWSMouseHandler QCalibratedMouseHandler 0195 QAutoMouseHandlerPrivate QWSMouseHandlerPrivate QVrTPanelHandlerPrivate 0196 QTPanelHandlerPrivate QYopyTPanelHandlerPrivate QCustomTPanelHandlerPrivate 0197 QVFbMouseHandlerPrivate) 0198 (qwsproperty_qws.h QWSPropertyManager) 0199 (qwsregionmanager_qws.h QWSRegionManager) 0200 (qwssocket_qws.h QWSSocket QWSServerSocket) 0201 (qwswindowsdecoration_qws.h QWSWindowsDecoration) 0202 (qstatusbar.h statusBar()) 0203 0204 ; Useful fake entries 0205 (qapplication.h qApp) 0206 (qglobal.h qDebug qWarning) 0207 (qeventloop.h eventloop) 0208 )) 0209 0210 (defvar kdab-qt4-special-includes 0211 '( 0212 ; Useful fake entries 0213 (QApplication qApp) 0214 (QDebug qDebug qWarning) 0215 (QEventLoop eventloop) 0216 )) 0217 0218 (defvar kdab-qpe-includes 0219 '( 0220 (alarmserver.h AlarmServer) 0221 (applnk.h AppLnk DocLnk AppLnkSet DocLnkSet) 0222 (calendar.h Calendar) 0223 (categories.h CategoryGroup CategoryGroup Categories CheckedListView) 0224 (categorymenu.h CategoryMenu) 0225 (categoryselect.h CategoryCombo CategorySelect CategoryEdit CategoryWidget) 0226 (config.h Config) 0227 (contact.h Contact) 0228 (database.h QWSDatabase DatabaseDefaultView Database DatabaseView DatabaseDefaultView) 0229 (datebookdb.h DateBookDB) 0230 (datebookmonth.h DateBookMonthHeader DayItemMonth DateBookMonthTable DateBookMonth DateButton) 0231 (event.h Event EffectiveEvent EffectiveEventSizeSorter EffectiveEventTimeSorter) 0232 (filemanager.h FileManager) 0233 (fileselector.h FileSelectorItem FileSelector) 0234 (finddialog.h FindDialog) 0235 (fontdatabase.h FontDatabase) 0236 (fontmanager.h FontManager) 0237 (global.h Global) 0238 (imageedit.h ImageEdit) 0239 (inputmethodinterface.h InputMethodInterface) 0240 (ir.h Ir) 0241 (lightstyle.h LightStyle) 0242 (lnkproperties.h LnkProperties) 0243 (mediaplayerplugininterface.h MediaPlayerDecoder) 0244 (menubutton.h MenuButton) 0245 (mimetype.h MimeType) 0246 (network.h Network) 0247 (palmtoprecord.h Record) 0248 (palmtopuidgen.h UidGen) 0249 (password.h Password) 0250 (power.h PowerStatus PowerStatusManager ) 0251 (process.h Process) 0252 (qcopenvelope_qws.h QCopEnvelope) 0253 (qdawg.h QDawg) 0254 (qlibrary.h QLibrary) 0255 (qpeapplication.h QPEApplication) 0256 (qpedecoration_qws.h QPEDecoration QPEManager) 0257 (qpedialog.h QPEDialogListener) 0258 (qpemenubar.h QPEMenuToolFocusManager QPEMenuBar) 0259 (qpemessagebox.h QPEMessageBox) 0260 (qpestyle.h QPEStyle : public QWindowsStyle) 0261 (qpetoolbar.h QPEToolBar) 0262 (record.h Record) 0263 (resource.h Resource) 0264 (sound.h Sound) 0265 (storage.h StorageInfo FileSystem) 0266 (task.h Task) 0267 (timeconversion.h TimeConversion) 0268 (timestring.h DateFormat TimeString) 0269 (tzselect.h TZCombo TimeZoneSelector) 0270 )) 0271 0272 ; List of classes in Qt4 that don't start with a Q. 0273 (defvar kdab-qt4-classes 0274 '(ActiveQt) ) 0275 0276 ;; ------------------------------ SOURCE CODE ------------------------------ 0277 0278 ;; build Qt4 special include list 0279 (defun kdab-build-qt4-special-includes () 0280 (let ( elm (res kdab-qt4-special-includes) (list kdab-qt4-classes)) 0281 (while list 0282 (progn 0283 (setq elm (car list)) 0284 (setq list (cdr list)) 0285 (setq res (cons (list elm elm ) res )))) 0286 res)) 0287 0288 (defun kdab-build-qpe-special-incldues () 0289 (let (elm header classes (list kdab-qpe-includes) filename (result '())) 0290 (while list 0291 (setq elm (car list)) 0292 (setq list (cdr list)) 0293 (setq filename (concat (if kdab-prefix-qpe "qtopia/" "") (symbol-name (car elm)))) 0294 (setq result (cons (cons (intern filename) (cdr elm)) result))) 0295 result)) 0296 0297 (defun kdab-join-lists (list1 list2) 0298 (let ((res list1) 0299 (list list2) 0300 elm) 0301 (while list 0302 (progn 0303 (setq elm (car list)) 0304 (setq list (cdr list)) 0305 (setq res (cons elm res)))) 0306 res)) 0307 0308 (defun kdab-get-special-include-list () 0309 (kdab-join-lists kdab-private-special-includes 0310 (kdab-join-lists kdab-special-includes 0311 (kdab-join-lists (if (eq kdab-qt-version 3) kdab-qt3-special-includes 0312 (if (eq kdab-qt-version 4) (kdab-build-qt4-special-includes) '())) 0313 (if kdab-include-qpe (kdab-build-qpe-special-incldues) '()))))) 0314 0315 ;; Lookup class `cls' in kdab-special-includes and return the associate include file name 0316 (defun kdab-map-special (cls) 0317 (let ((list (kdab-get-special-include-list)) 0318 (found nil)) 0319 (while (and list (not found)) 0320 (let* ( (elm (car list)) 0321 (include-file (car elm)) 0322 (classes (cdr elm))) 0323 ( while (and classes (not found)) 0324 (if (string= (downcase cls) (downcase (symbol-name (car classes)))) 0325 (setq found include-file) 0326 (setq classes (cdr classes))))) 0327 (setq list (cdr list))) 0328 (if found 0329 (symbol-name found) 0330 ; not found: check if starts with 'Q' 0331 (if (string-startsWith cls "Q") 0332 cls ; assume a Qt-4 forwarding header exists for the class 0333 nil)) ; return value 0334 )) 0335 0336 0337 0338 ;-------------------------------------------------------------------------------- 0339 ; Insert include file for Qt program. 0340 ; Place point anywhere on a Qt class, and invoke this function. A result of 0341 ; this is that an include line is added (if it does not already exists) for 0342 ; the given class. 0343 ;-------------------------------------------------------------------------------- 0344 (defun kdab-insert-header ( prefix ) 0345 "Insert include file for class at point" 0346 (interactive "P") 0347 (save-excursion 0348 (let* ((word-at-point (if prefix 0349 (read-from-minibuffer "Class: ") 0350 (current-word)))) 0351 (kdab-insert-header-non-interactive word-at-point)))) 0352 0353 ;-------------------------------------------------------------------------------- 0354 ; insert include file for `word-with-case' non-interactively. 0355 ; for an interactive version see kdab-insert-header 0356 ;-------------------------------------------------------------------------------- 0357 (defun kdab-insert-header-non-interactive (word-with-case) 0358 (save-excursion 0359 (let* ((word (downcase word-with-case)) 0360 (special-header (cond 0361 ((kdab-map-special word) (kdab-map-special word)) 0362 ((and (string-match "^qdom" word) (eq kdab-qt-version 3)) "qdom.h") 0363 ((and (string-match "^qxml" word) (eq kdab-qt-version 3)) "qxml.h") 0364 ((and (string-match "^q" word) (eq kdab-qt-version 3)) (concat word ".h") ) 0365 ((and (string-match "^q" word) (eq kdab-qt-version 4)) word-with-case ) 0366 (kdab-lowercase-header-files (concat word ".h" )) 0367 (t (concat word-with-case ".h")))) 0368 header is-local override) 0369 0370 ;; decide on the header file. 0371 (if (functionp 'kdab-name-include-file) 0372 (setq override (kdab-name-include-file word-with-case))) 0373 0374 (if override 0375 (progn ;; Users hook solved it for us. 0376 (setq header (car override)) 0377 (setq is-local (cdr override))) 0378 (if (file-exists-p (concat word-with-case ".h")) 0379 (progn ; file exists in given case in pwd. 0380 (setq header (concat word-with-case ".h")) 0381 (setq is-local 't)) 0382 (if (file-exists-p (concat word ".h")) ; file exists in lowercase in pwd 0383 (progn 0384 (setq header (concat word ".h")) 0385 (setq is-local 't)) 0386 (if (file-exists-p word-with-case) 0387 (progn 0388 (setq header word-with-case) 0389 (setq is-local 't)) 0390 (if (file-exists-p word) 0391 (progn 0392 (setq header word) 0393 (setq is-local 't)) 0394 (progn ; header in <..> path 0395 (setq header special-header) 0396 (setq is-local nil))))))) 0397 0398 (kdab-insert-include-file header is-local t)))) 0399 0400 ;-------------------------------------------------------------------------------- 0401 ; Insert header file for header. If is-local insert it with "" 0402 ; otherwise insert it with <> 0403 ;-------------------------------------------------------------------------------- 0404 (defun kdab-insert-include-file (header is-local show-message) 0405 (let ((include-file (if is-local 0406 (concat "#include \"" header "\"") 0407 (concat "#include <" header ">")))) 0408 0409 (beginning-of-buffer) 0410 ; first look for //#include "foo.h" being already there 0411 (if (re-search-forward (concat "^ *// *\\(#include *[<\"][ \t]*" header "[ \t]*[>\"]\\)") nil t) 0412 (progn 0413 (replace-match "\\1") 0414 (when show-message 0415 (message (concat "commented in #include for " header)))) 0416 0417 (if (not (re-search-forward (concat "#include *[\"<][ \t]*" header "[ \t]*[\">]") nil t)) 0418 (kdab-insert-header-from-end include-file show-message) ;; No include existed 0419 (when show-message 0420 (message (concat "header file \"" header "\" is already included"))))))) 0421 0422 ;-------------------------------------------------------------------------------- 0423 ; Insert header file starting the search from behind. This is a helper function for 0424 ; kdab-insert-include-file 0425 ; Historically kdab-insert-include-file added the include file at the end of the list 0426 ; of include files, which had the unfortunate effect that it sometimes inserted the 0427 ; include into #ifdef'ed sections. 0428 ; So now we insert it at the top of the list. We need to go after the include for 0429 ; the source files own header. 0430 ;-------------------------------------------------------------------------------- 0431 (defun kdab-insert-header-from-end (include-file show-message) 0432 (let ((basename (file-name-nondirectory (file-name-sans-extension (buffer-file-name)))) 0433 found-own-include found-any-include) 0434 (goto-char (point-max)) ; Using end-of-buffer makes point move, despite save-excursion 0435 (setq found-own-include 0436 (re-search-backward (concat "^[ \t]*#[ \t]*include[ \t]*[\"<]" basename "\\(" 0437 kdab-suffix-for-private-headers "\\)?\\(.h\\)?[\">]") nil 't)) 0438 0439 (if found-own-include 0440 (progn ; Found an include for my own header file 0441 (next-line 1) 0442 (beginning-of-line)) 0443 (progn ; Did not find a local include - we will then insert before first include 0444 (beginning-of-buffer) 0445 (setq found-any-include (re-search-forward "^[ \s]*#include[ \t]*[\"<]\\([^\">]+\\)[\">]" nil t)) 0446 (if found-any-include 0447 (beginning-of-line) ;; OK we found some include 0448 (beginning-of-buffer)))) ;; None found at all. 0449 0450 ;; Now insert the header 0451 (insert (concat include-file "\n")) 0452 (when show-message 0453 (message (concat "inserted " include-file))))) 0454 0455 0456 ;---------------------------------------------------------------------------- 0457 ; Insert a forward declaration for a Qt class. 0458 ; Place point anywhere on a Qt class, and invoke this function. A 0459 ; result of this is that a forward declaration line is added (if it does 0460 ; not already exist) for the given class. 0461 ;---------------------------------------------------------------------------- 0462 (defun kdab-insert-forward-decl ( prefix ) 0463 (interactive "P") 0464 (save-excursion 0465 (let* ((word (if prefix (read-from-minibuffer "Class: ") 0466 (current-word)))) 0467 (beginning-of-buffer) 0468 (if (re-search-forward (concat "^ *// *\\(class *" word ";\\)") nil t) 0469 (progn 0470 (replace-match "\\1") 0471 (message (concat "commented in forward declaration for " word))) 0472 0473 (if (not (re-search-forward (concat "class *" word ";") nil t)) 0474 (progn 0475 ; No forward decl existed 0476 ; Look for other forward declarations and insert this one before them 0477 ; (this avoids finding class Private; inside a class, or other stuff in the middle of the file) 0478 (if (re-search-forward "^[ \t]*class .*;" nil t) 0479 (progn 0480 ; Exit namespace foo { class bar; } if necessary 0481 ; This is a modified version of (backward-up-list) which doesn't 0482 ; throw an error when not found. 0483 (goto-char (or (scan-lists (point) -1 1 nil t) (point))) ; ### do multiple times if necessary 0484 (re-search-backward "^[ \t]*namespace " nil t) ; in case of namespace foo\n{ 0485 (beginning-of-line)) 0486 ; No forward declarations found, lets search for include lines. 0487 ; For those we start from the end, because we want to leave file.h first. 0488 (progn (goto-char (point-max)) 0489 (if (re-search-backward "#include" nil t) 0490 (progn (end-of-line) (forward-char 1)) 0491 (beginning-of-buffer)))) 0492 0493 (progn 0494 (insert "class " word ";\n") 0495 (message (concat "inserted class " word ";")))) 0496 (message (concat "forward decl for \"" word "\" already exists"))))))) 0497 0498 0499 (defun is-qpe-class (class) 0500 (let ((list kdab-qpe-includes) classes (found nil)) 0501 (while (and (not found) list) 0502 (setq classes (cdr (car list))) 0503 (while classes 0504 (if (string= (downcase (symbol-name (car classes))) (downcase class)) 0505 (setq found 't)) 0506 (setq classes (cdr classes))) 0507 (setq list (cdr list))) 0508 found)) 0509 0510 0511 (provide 'klaralv)