Comments (4)
This is a known issue, and it is not simple to fix. The workaround is to use begin/end
blocks around the nested if statements, as in the example below. I pushed a fix for indenting an end if
line when there's an elsif
in the if-else chain, see deb9885.
Unfortunately, I do not have time to fix this issue. If you want to try fixing it, the problem is that sqlind-beginning-of-statement-1
does not detect the beginning of the statement correctly for nested if blocks, so the sqlind-syntax-of-line
function computes an incorrect syntax.
begin
if 1 = 0 then
begin
if 1 = 0 then
null;
else
null;
end if;
end;
elsif 1 = 2
begin
if 1 = 0 then
null;
else
null;
end if;
end;
else
null;
end if;
end;
/
from emacs-sql-indent.
Thanks for the hint. Unfortunately I must work with existing code and I can't enclose If blocks.
I'll try to work on this. Thanks for the start point.
from emacs-sql-indent.
After a bit of thinking I think I got this working. Can you please try it out and see if it OK?
I wrote this code about 10 years ago and back than this seemed like a hard task...
from emacs-sql-indent.
Whaou, You're faster than light !!!
Many thanks for fixing this. And you've maybe wrote this code 10 years ago but it's always useful (at least for me).
from emacs-sql-indent.
Related Issues (20)
- Postgresql perform keyword HOT 7
- Postgresql end if indentation HOT 2
- Indentation fails with IF EXISTS clause HOT 1
- Incorrect indentation after "drop function if exists" HOT 2
- mysql elseif keyword not recognized HOT 2
- Keywords in comments used for alignment HOT 2
- `BEGIN' block never ends unless optional keywords are used
- "left outer" not recognised as join by sqlind-lineup-joins-to-anchor HOT 4
- Please make it easy to define new products HOT 1
- Bad indentation for CREATE SCHEMA IF NOT EXISTS HOT 2
- Bad indentation for CREATE TRIGGER FOR ROW HOT 4
- PostgreSQL DO blocks throws "end statement closes nothing" when encountering a CREATE statement HOT 2
- Bad indentation for COMMENT ON FUNCTION HOT 3
- Bad indentation for DECLARE in PostgreSQL HOT 5
- indent does not work on parenthese group HOT 8
- Indentation for blocks with blank lines HOT 2
- org-mode source blocks? HOT 14
- PostgreSQL CREATE EXTENSION IF NOT EXISTS HOT 2
- autoloading failed HOT 2
- Align "As" within a JOIN HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emacs-sql-indent.