Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3999650
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:41:05+00:00 2026-05-20T07:41:05+00:00

Background I have a function dbquery that simplifies the process of querying a MySQL

  • 0

Background

I have a function dbquery that simplifies the process of querying a MySQL database from within R.

dbquery <- function(querystring) {
  dvr <- dbDriver("MySQL")
  con <- dbConnect(dvr, group = "databasename")
  q <- dbSendQuery(con, querystring)
  data <- fetch(q, n = -1)
  return(data)
}    

Thus I can send:

dbquery(querystring = "select field_1, field_2, field_3 
                       from table_a join table_b on this = that 
                       join table_c on that = something 
                       where field_4 in (1,2,3);"

However, the variable querystring must be contained within quotes. This makes it so that Emacs ESS will not nicely indent my queries like it would if it were in SQL mode – or even like it does if there are no quotes but just in ESS-R mode.

Question

Is it possible to get ESS to do this? Perhaps by writing the function so that it will accept the query without a quote (and add the quotes within the function), or perhaps adding something to .emacs or ess.el?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:41:05+00:00Added an answer on May 20, 2026 at 7:41 am

    I think what you want in MMM Mode. As his name suggests: MultiMajorMode Mode allows to have multiple modes on different regions of the same buffer.

    I recommend that you checkout the examples in http://www.emacswiki.org/emacs/HtmlModeDeluxe as they will probably give you an idea how to do it in your case (you might want to add some comment in your code around the sql so that MMM can find the sql code).

    You would have to do something like this I guess (untested):

    (require 'mmm-mode)
    (mmm-add-group
         'sql-in-ess
         '(
                 (sql-query
                        :submode sql-mode
                        :face WHATEVERYOUWANT
                        :front "#SQL_QUERY>"
                        :back "#<SQL_QUERY"))
    (add-to-list 'mmm-mode-ext-classes-alist '(ess-mode nil sql-in-ess))
    

    However, this might be overkill, unless it happens a lot that you have complex sql queries in the R code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: we have an application that generates reports from HTML (that may or may
Background: I have a function in my program that takes a set of points
I have a function that returns a bitmap meant to be used as background
i have function that changes background color of element and src of image. in
Background: Suppose I have a powershell function that understands and interprets small_commands such as:
Background: I have a webpage that lists latest 30 tweets from twitter. But every
Background : I have built a tool that imports sales orders from Magento to
I have a small function that will take a string of css (eg background:
I have a function on a background thread that looks like this: NSMutableArray *descriptions
following background: i have a Table-valued Function that returns a Table that is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.