Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into sources-wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersbakken committed Oct 18, 2016
2 parents 0c30aeb + e1abfb1 commit 771f10c
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 88 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.6)
project(rtags)
set(RTAGS_VERSION_MAJOR 2)
set(RTAGS_VERSION_MINOR 5)
set(RTAGS_VERSION_DATABASE 103)
set(RTAGS_VERSION_DATABASE 104)
set(RTAGS_VERSION_SOURCES_FILE 7)
set(RTAGS_VERSION ${RTAGS_VERSION_MAJOR}.${RTAGS_VERSION_MINOR}.${RTAGS_VERSION_DATABASE})

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ endif ()
set(RTAGS_ELISP_FILES
rtags.el
rtags-ac.el
rtags-helm.el
company-rtags.el
flycheck-rtags.el)

Expand Down
2 changes: 1 addition & 1 deletion src/ClangIndexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ String ClangIndexer::addNamePermutations(const CXCursor &cursor, Location locati
trailer = type.mid(idx);
}
const int paren = type.indexOf('(');
if (paren != -1) {
if (paren != -1 && (paren != 8 || !type.startsWith("decltype("))) {
type.resize(paren);
} else if (!type.isEmpty() && !type.endsWith('*') && !type.endsWith('&')) {
type.append(' ');
Expand Down
2 changes: 1 addition & 1 deletion src/CompletionThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ struct Output
connection->write(string);
connection->finish();
} else {
output->log(string.constData(), string.size());
output->log(string.constData());
}
}
std::shared_ptr<LogOutput> output;
Expand Down
6 changes: 3 additions & 3 deletions src/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,10 +742,10 @@ void Project::onJobFinished(const std::shared_ptr<IndexerJob> &job, const std::s
}
if (options.options & Server::Progress) {
if (format == QueryMessage::XML) {
output->log("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<progress index=\"%d\" total=\"%d\"></progress>",
idx, mJobCounter);
output->vlog("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<progress index=\"%d\" total=\"%d\"></progress>",
idx, mJobCounter);
} else {
output->log("(list 'progress %d %d)", idx, mJobCounter);
output->vlog("(list 'progress %d %d)", idx, mJobCounter);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/rct
114 changes: 114 additions & 0 deletions src/rtags-helm.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
;;; rtags-helm.el --- A front-end for rtags

;; Copyright (C) 2011-2015 Jan Erik Hanssen and Anders Bakken

;; Author: Jan Erik Hanssen <[email protected]>
;; Anders Bakken <[email protected]>
;; URL: http://rtags.net
;; Version: 2.3.94

;; This file is not part of GNU Emacs.

;; This file is part of RTags (http://rtags.net).
;;
;; RTags is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; RTags is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with RTags. If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;;; Code:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Helm integration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'rtags)
(require 'helm)

(defcustom rtags-helm-actions
'(("Select" . rtags-helm-select)
("Select other window" . rtags-helm-select-other-window))
"RTags helm actions.
Each element of the alist is a cons-cell of the form (DESCRIPTION . FUNCTION)."
:group 'rtags
:type '(alist :key-type string :value-type function))

(defun rtags-helm-candidates ()
(let ((buf (get-buffer rtags-buffer-name))
(ret))
(when buf
(with-current-buffer buf
(save-excursion
(goto-char (point-min))
(when (looking-at "Functions called from:")
(forward-line 1))
(let (done)
(while (not done)
(push (cons (buffer-substring-no-properties (point-at-bol) (point-at-eol)) (point-at-bol)) ret)
(if (= (point-at-eol) (point-max))
(setq done t)
(forward-line 1)))))))
ret))

(defun rtags-helm-select (candidate)
(with-current-buffer (get-buffer rtags-buffer-name)
(goto-char candidate)
(rtags-select nil nil)))

(defun rtags-helm-select-other-window (candidate)
(with-current-buffer (get-buffer rtags-buffer-name)
(goto-char candidate)
(rtags-select t nil)))

;; (message "CAND: %d" (get-text-property 0 'rtags-buffer-position candidate)))

(defun rtags-helm-get-candidate-line (candidate)
(with-current-buffer (get-buffer rtags-buffer-name)
(goto-char candidate)
(buffer-substring-no-properties (save-excursion
(goto-char (point-at-bol))
(skip-chars-forward " ")
(point))
(point-at-eol))))

(defun rtags-helm-select-persistent (candidate)
(let ((line (rtags-helm-get-candidate-line candidate)))
(rtags-goto-location line t nil)
(helm-highlight-current-line)))

(defface rtags-helm-file-face
'((t :inherit font-lock-keyword-face))
"Face used to highlight file name in the *RTags Helm* buffer."
:group 'rtags)

(defface rtags-helm-lineno-face
'((t :inherit font-lock-doc-face))
"Face used to highlight line number in the *RTags Helm* buffer."
:group 'rtags)

(defun rtags-helm-transform (candidate)
(let ((line (rtags-helm-get-candidate-line candidate)))
(when (string-match "\\`\\([^:]+\\):\\([0-9]+\\):\\([0-9]+\\):\\(.*\\)" line)
(format "%s:%s:%s:%s"
(propertize (match-string 1 line) 'face 'rtags-helm-file-face)
(propertize (match-string 2 line) 'face 'rtags-helm-lineno-face)
(propertize (match-string 3 line) 'face 'rtags-helm-lineno-face)
(match-string 4 line)))))

(defvar rtags-helm-source nil)
(setq rtags-helm-source '((name . "RTags Helm")
(candidates . rtags-helm-candidates)
(real-to-display . rtags-helm-transform)
(action . rtags-helm-actions)
(persistent-action . rtags-helm-select-persistent)))

(provide 'rtags-helm)
84 changes: 3 additions & 81 deletions src/rtags.el
Original file line number Diff line number Diff line change
Expand Up @@ -4668,87 +4668,9 @@ the user enter missing field manually."
"[ \t\n]+" " "
(replace-regexp-in-string "\n" " " doc)))))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Helm integration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(with-eval-after-load 'helm
(defcustom rtags-helm-actions
'(("Select" . rtags-helm-select)
("Select other window" . rtags-helm-select-other-window))
"RTags helm actions.
Each element of the alist is a cons-cell of the form (DESCRIPTION . FUNCTION)."
:group 'rtags
:type '(alist :key-type string :value-type function))

(defun rtags-helm-candidates ()
(let ((buf (get-buffer rtags-buffer-name))
(ret))
(when buf
(with-current-buffer buf
(save-excursion
(goto-char (point-min))
(when (looking-at "Functions called from:")
(forward-line 1))
(let (done)
(while (not done)
(push (cons (buffer-substring-no-properties (point-at-bol) (point-at-eol)) (point-at-bol)) ret)
(if (= (point-at-eol) (point-max))
(setq done t)
(forward-line 1)))))))
ret))

(defun rtags-helm-select (candidate)
(with-current-buffer (get-buffer rtags-buffer-name)
(goto-char candidate)
(rtags-select nil nil)))

(defun rtags-helm-select-other-window (candidate)
(with-current-buffer (get-buffer rtags-buffer-name)
(goto-char candidate)
(rtags-select t nil)))

;; (message "CAND: %d" (get-text-property 0 'rtags-buffer-position candidate)))

(defun rtags-helm-get-candidate-line (candidate)
(with-current-buffer (get-buffer rtags-buffer-name)
(goto-char candidate)
(buffer-substring-no-properties (save-excursion
(goto-char (point-at-bol))
(skip-chars-forward " ")
(point))
(point-at-eol))))

(defun rtags-helm-select-persistent (candidate)
(let ((line (rtags-helm-get-candidate-line candidate)))
(rtags-goto-location line t nil)
(helm-highlight-current-line)))

(defface rtags-helm-file-face
'((t :inherit font-lock-keyword-face))
"Face used to highlight file name in the *RTags Helm* buffer."
:group 'rtags)

(defface rtags-helm-lineno-face
'((t :inherit font-lock-doc-face))
"Face used to highlight line number in the *RTags Helm* buffer."
:group 'rtags)

(defun rtags-helm-transform (candidate)
(let ((line (rtags-helm-get-candidate-line candidate)))
(when (string-match "\\`\\([^:]+\\):\\([0-9]+\\):\\([0-9]+\\):\\(.*\\)" line)
(format "%s:%s:%s:%s"
(propertize (match-string 1 line) 'face 'rtags-helm-file-face)
(propertize (match-string 2 line) 'face 'rtags-helm-lineno-face)
(propertize (match-string 3 line) 'face 'rtags-helm-lineno-face)
(match-string 4 line)))))

(defvar rtags-helm-source nil)
(setq rtags-helm-source '((name . "RTags Helm")
(candidates . rtags-helm-candidates)
(real-to-display . rtags-helm-transform)
(action . rtags-helm-actions)
(persistent-action . rtags-helm-select-persistent))))

(eval-after-load "helm"
'(require 'rtags-helm))

(provide 'rtags)

Expand Down

0 comments on commit 771f10c

Please sign in to comment.